Tuesday, October 20, 2009

New Youtube AS3 API

That sound you hear is angels singing hallelujah whilst beams of light shine down upon our unworthy faces. Youtube have finally released an AS3 version of their chromeless API:

http://code.google.com/apis/youtube/flash_api_reference.html

If only they'd have released it 2 months ago.

Initially it's fantastic and really easy to use. The code example works, you can monitor and change the video quality and it's fairly smooth. Then the record scratches and you run into some problems.

Firstly the destroy(() function hasn't been implemented yet. At first glance this was a deal breaker, but someone else suggested using a hack and just requesting a non-existent video, which stops the stream. player.loadVideoById("Youtube are jokers") works well, though if I was building an app that was showing lots and lots of different video (the one I'm on will probably only have 5-10 max) I would be concerned.

Also the embed code coming from it doesn't work. This is less serious (I was very tempted to just leave it and hope no one noticed until Youtube fixed it) but I'm still not sure how to find a nice workaround. I might have to just write a function that manually assembles the code. Not optimal but it will probably work.

Monday, October 05, 2009

Ripples

I've just released a new game, Ripples . I'm going for a chilled, atmospheric version of Every Extend. Lots of BevelFilter and some dodgy focalLength fake 3d hacked to bits. The premise and gameplay is purely derivitive but I thing the music, look and feel make up for it.

I'm releasing it as self sponsored to try to drive traffic to my site. We'll see how that goes. What I really need to do it write some script to catch how many people actually click the 'play more game' button. We'll see how it goes.

Thursday, September 24, 2009

More Flash youtube fun



This works pretty well, though flex debugger seems to sometimes interfere and break it, making it a bit of a challenge to develop.

As it seems it has to be the case with youtube it mostly works, but not totally, the problem here being with the error handling. According to the documentation it should dispatch an event when the youtube video is either not found or is not available for embedding. It didn’t. After doing some checking and verifying that it wasn’t my code I opened up YoutubeLoader.as and found that there was nothing in there to handle any errors coming from the javascript. I then checked the javascript and found that there was also nothing in there to send or receive error messages from the as2 youtube player you’ve loaded in.

Simples, I think. I amended the javascript to catch the errors from the as2 player, then added in code in YoutubeLoader.as to catch the externalInterface calls. Feeling very smug I tested it out. I found that youtube are bollocks. A working youTube video always dispatches a 100 error, right at the start. This is the error for video not found. When video is not found it is also dispatches this error. There is no way of telling them apart. It does however send the 150/101 error correctly, which is the error for when the video is there but you’re not allowed to embed it.

So my solution is to keep in the error catching functions I added to catch when the video is there, but not allowed, then put in something that makes a request to the youtube api for the info on that video. If the ID is wrong or the video doesn’t exist then this will fail. I don’t like having to split my error handling up but it seems to be the only way.

Why youtube can’t get a measly couple of flash devs together to write a solid working player with no bugs or surprises is beyond me.

My changes to youtubeLoader.js:

function onYouTubePlayerReady(playerId) {
if (checkObj()) {
obj.addEventListener("onStateChange", "onytplayerStateChange");
obj.addEventListener("onError", "onytplayerError");
}
}
function onytplayerError(newState) {
//alert("Player's new state: " + newState);
obj.playerErrorHandler(newState);
}

My changes to youtubeLoader.as:

ExternalInterface.addCallback( "playerErrorHandler", playerErrorHandler);//Added to constructor
private function playerErrorHandler(errorCode:String):void
{
var e:YouTubeLoaderEvent = new YouTubeLoaderEvent(YouTubeLoaderEvent.IO_ERROR);
e.state = errorCode;
dispatchEvent(e);
}

Wednesday, September 23, 2009

Flash youtube nightmares.

So at work I’m working on a project that requires that youtube videos be embedded and controlled in an AS3 site. Unfortunately those lazy bastards at youtube still only have an AS2 chromeless player. This means that when you load it into your AS3 movie you can’t control it directly, you have to go through either local connection or javascript.

After a quick bit of research I decided on going the localConnection route, using TubeLoc, a nice and easy wrapper that loads in a ready made as2 swf and communicates using localConnection. Pretty simple and easy and I thought I had it cracked. Then we tested it around the office and found that it wouldn’t work on any of the office macs. It would work occasionally, but not reliably.

I got the tech department to set me up with a macbook myself so I could do some tests and research and found some pretty horrifying things. I found lots of people referring to localConnection not working correctly on Macs, especially since the last flash player update ( 10.0.32.18). Indeed, adobe did make a big change to how localConnection works on macs in that update, though they swear blind that it should be fully backwards compatible.

To test I made 2 swfs that use localConnection to simply send the contents of a text field back and forth. These worked perfectly on a PC, but on sporadically on the mac when I rebooted.

After this I concluded that I couldn’t trust localconnection, and so went over to the javascript method for the youtube api. This works, though it is a bit of a hassle, and it means that you can only test in a web-browser with the correct html and files.

If anyone has any suggestions I would love to hear them, otherwise I just wish Youtube would get off their arses and make an AS3 version of the player.

My localConnection test (switch LocalConnectionTest0 and LocalConnectionTest1 and save with different names - make sure you drag onto the browser as you standalone flash player probably won't be latest version):

package {
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.net.LocalConnection;
import flash.text.TextField;
import flash.text.TextFieldType;


public class LocalConnectionTest extends Sprite
{

private var receivingConnection :LocalConnection;
private var sendingConnection :LocalConnection;
private var inputTF :TextField;
private var outPuTF :TextField;

public function LocalConnectionTest()
{
receivingConnection = new LocalConnection();
receivingConnection.client = this;
receivingConnection.connect("LocalConnectionTest0");


sendingConnection = new LocalConnection();

inputTF = new TextField();
inputTF.type = TextFieldType.INPUT;
addChild(inputTF);
outPuTF = new TextField();
outPuTF.x = 200;
addChild(outPuTF);

var btn:Sprite = new Sprite();
addChild(btn);
btn.graphics.beginFill(0);
btn.graphics.drawCircle(100, 100, 20);
btn.addEventListener(MouseEvent.CLICK, send);
}

public function onLocalConnectionEvent(object_p:Object):void
{
inputTF.text = object_p.text;
}

public function send(evt:MouseEvent):void
{
sendingConnection.send("LocalConnectionTest1", "onLocalConnectionEvent", {text:inputTF.text});
inputTF.text = "";
}
}
}



Monday, September 14, 2009

The ethics of flash games sites.

OK, so I have my distinctly low rent flash games site up and running. While I am pleased I’m not 100% happy. This is because deep down I think that there is something deeply scummy and unethical about running this kind of site. The whole concept strikes me as being faintly parasitic. Essentially I’m trying to build a site using other people’s content without really adding any value of my own. I keep on telling myself 'hey, this is how the web works'. To an extent that's true - look at aggregator sites like the Huffington post, but that doesn't really say much. At least I'm not doing the Ebaum's world thing and pretending the games are mine.

A large part of my dislike for this kind of site stems from the fact that when I first started in flash game there was no Mochi ads, and my first, most popular games pretty much earned me nothing, despite clocking up millions of plays between them. None of my more recent, Mochi enabled games have been anywhere near as successful (lack of competition back then probably) and I’ve never been able to make any decent cash out of my games. Something I’m still oh so slightly bitter about.

Luckily now things are different. Mochi ads have changed everything, in that if someone has ads at the beginning of their game then any hits are good hit no matter where they come from. The other common way for game creators to make cash is by selling sponsorship, and I guess for that purpose any hits are good hits. I try to only put up games that are either clearly sponsored or have ads.

At some point I may try sponsoring some games myself, but as the moment I don't have the cash for that or the site/ad to take advantage of any upticks I may get. To be honest if I wanted to sponsor some good games that would actually generate some traffic I'd be up against the big boys anyway, and I don't think I'm up for that. At the moment the site is still a spare time hobby thing. Once you start sponsoring you need lawyers, accountants etc.

So, for the moment I'm going to try to carry on like this. I have a few games in the works, but my day job has really picked up and I'm not sure when I'll have enough time to look at them. Then I can start adding some games of my own and actually feel like the site isn't so worthless.

Wednesday, September 02, 2009

Sam's guide to freelancing
Part 1: Making an impression*  
Or rather, not making the wrong type of impression. 
This relates to two different facets of freelancing in digital agencies. The first is that most small to medium size agencies seem to have large tech departments, and as a consequence a gender spread of about 2 men for every woman. Unfortunately in too many case for me to count they will also have only 2 toilets and despite the gender disparity they divide them into one men's and one women's.  
The second is that at least initially people won't know who you are. Actually the chance are that they'll probably never know who you are unless they've worked with you directly. This means that if they need to refer to you down the line, say when they need more resource or (more likely) the project you worked on develops bug, they'll think of whatever first spring to mind.  
'Remember that big freelancer guy we had in?' 
 'You mean the dashingly handsome one?'  
'No, the morbidly obese one, you know, the one with really bad BO.'  
'Oh! That guy who did that huge dump in the women's toilet and we had to call the plumber?'  
Bingo. Don't let this be you.

*This may, or may not become an ongoing series depending on whether or not I can think of more nuggets of wisdom to share. And if I can be bothered.

Friday, August 28, 2009

Bug Squad post mortem




I made and release this game a month ago, but I've only just had time to write it up here.

It all started about 4-5 months ago when there was the first swine flu scare. I had an idea for a dumb game about shooting pigs and got it as far as being able to shoot circles with other circles. I then got a contract and forgot about it. After that was finished I had a bit of time off and finished it off. I decided to keep it as a dumb game about shooting pigs and concentrate my engergies on the production values.

I think I succeeded in making a game that looks really nice and has rocking music, but I'm not so happy with the gameplay. It works to a point, but I think that I may have over-simplified it. I was aiming for a combo building high-score game and it's works as that, to a point. The mistake I made was than I didn't make it short and snappy enough (check out Boomshine for a good example of this) to work as this type of game. Also it has a huge problem in that if you don't go for the combos it's possible to survive for a really long time just by being click happy, but that if you do this it's a fairly boring game.


I did put it on the forums at flashgame license and I got some good feedback, but no-one picked up on the last point, and I was too close to the game to see it myself. I only realised after the game had been released when I was showing it to my family, and I actually got to watch them play. I'm absolutely gutted about that because it would have been fairly simple to have cut down the shot speed and thereby eliminate this as a viable mode of play. This just shows the huge limits of bedroom development. I'll have to make sure I can watch people play any subsequent games before putting them out.

Given it's drawbacks I can see now why I was unable to get what I would consider a decent payment for the sponsorship, and I'll just have to take it on the chin a try to learn the lesson for my future projects.

Sunday, August 23, 2009

PureMVC

So I've just started work at new digital agency, and it's the second one in a row where there have been lots of people gushing over PureMVC. In the past I've also been asked by recruiters if it's something I know, so I finally decided to try to get my head round it.

I've put aside another project I was working on since it was too far progressed and started a new one that may be more suited. It's a take/rip-off on the cool Dice Wars game, which I've wanted to do for a while, mostly because the AI programming interests me. It's also not a game that should require too much cpu, so the added overhead of the framework (and my mistakes in using it) shouldn't interfere too much. Also it's closer to an app or website than most of the games I do with lots of buttons, menus etc, so I hope it will actually be relevant to making sites in PureMVC.

My first impressions are... not great. It's about tripled the amount of code I think I'll need to write, and I've spent half of my time trying to work out where to stick what bit of code. My biggest issue is getting my head around the fact that in the tutorials I've read the controller/commands don't seem to do very much and most of the logic seems to be put in the proxies. I have a horrible feeling that if I were to show what I've done (and the final code) to a hardcore mvc guy they would facepalm.

Also what it makes me think is, do I really want to be a frameworks kind of programmer? There's nothing really that I can't do without frameworks, and for the projects I've been working on mostly up to now - micro-site, games etc I think they actually might be a hindrance. Am I just learning it so I can join the cool techie kids' gang? Or just to tick some boxes on a recruiter's form?

Anyway, I'm sure once I get my head round it I'll be spouting off about it to all the flash guys I know who haven't bothered with it. It's not what you know, it's the jargon.


Sunday, August 16, 2009

Fixed my google indexing problem
After a fair bit of tearing my hair out and frantic searching I finally managed to sort out my indexing problem, and the custom search used by google adsense for search works now. It turns out that the problem was that I was using relative paths in my linking, and somehow this meant that the page was calling some of the link recursively, causing the robot to die, even with a sitemap.xml still submitted. I changed my php so all my paths are now absolute and bingo, problem solved. I have no illusions as to this suddenly shooting me up the search ranking but as least it can not search within my site, making it looks that tiny bit less rank amateur.

The way I found the problems was first I looked at my page using a Lynx viewer. Lynx is a text based browser and I'm told that what it sees it very close to what the robots see. It saw lots of links that didn't work. I tried creating a sitemap at http://www.xml-sitemaps.com/, which is an awesome site. It generated a huge sitemap which had all 500 allowed links for the free version. I checked the forums there and saw references to the problem, changed my links and booyakasha, I now have a site that indexes. I used the sitemap generated there (I was so happy I even uncharacteristically made a donation) and now all my pages are showing up. Went back to lynx and now I can move around my site with Lynx, googlebots are happy and I can move on to my other problems.

Monday, August 10, 2009

New Site live!

I put the new version of my games site live last Wednesday. It was pretty much the first thing I did once we finally got the internet set up in our new house.

At first, of course there were lots of bugs, dead link where I had typos when uploading, and the rating system wasn't working, but that's all mostly fixed and I'm reasonably happy with how the site looks and works. At the moment it doesn't have very many games, so I'm going to try to get the numbers up as quickly as I can. As I said before, finding the right games and formatting them for upload is looking to be almost as big of a job as making the actual site.

My immediate plans are, in order of importance:
1.Get the search working properly.
This is a big issue. I'm trying to use the google site search, both so I don't have to write one myself and so I could potentially get ad revenue. My problem is that google doesn't seem to be referencing my pages - they're all dynamic links, but since you can get to every page from other pages in the site I assumed it would work it out. This doesn't seem to be the case. I'm going to look into it, but if I can't sort it quickly I'm going to have to ditch google and do my own one.
2. Change the thumbnail info to include rating and plays.
Hopefully this shouldn't be too much work. I just want to add the rating, date added and plays to the game thumbnails. Also I need to clean up the css and structuring of that element.
3. Make an admin page and image upload.
I really want to have a game upload page where I can enter in all the info and upload the image and swf. If I can do it properly so it error checks the paths and info I can avoid the annoying typo errors I've been making while uploading games using ftp and phpadmin.
4. Make and add some games.
In order to generate traffic I'm going to need to make some more games linking back to my site. Probably the hardest task, and I'm not sure when I'll next have time. I'm slightly regretting licensing Bug Squad, since it would be really cool to have a game to launch with.

I'm working on site at the moment at an agency, probably for the next week or two. I'm hoping that there will be a natural break where I can work, but I don't feel I can turn down work at the moment, and I don't expect the site to make any significant income in the near or medium term. Unfortunately if I don't pull my finger out it won't even in the long term. Oh well.

Friday, July 31, 2009

MY NEW GAMES PORTAL SITE
I've decided to turn my site, Utterly Superb into a general flash games site. This is partly as an experiment to see if I can make some cash and partly as a project to help me learn some more about php, MySql and CSS.

The main impetus is that I made a new game, Bug Squad and put it on a site called flash game licensing to try to get some money to sponsor it. I got a decent offer. It wasn't huge, and it certainly wasn't enough to cover the time I spent making the game, but it got me thinking. I figured, that if they were prepared to pay me an amount just to have their logo on the game, then it must be worth more than that to them in anticipated revenue. So I wondered, what would it take for it to be worth that much to me?

I already have a game site, with only my games on it. At the moment the ad revenue more than covers the cost of a hugely excessive hosting package, so if I were to increase the usage by 100 time I would still be within the allowance. My traffic isn't great, but I'm not starting from nothing, and I have an advantage over most of the games portals in that I'm the only person involved. So no lawyers, accoutants, partners etc. I can make games myself so no need to have an initial fund for sponsorship, and work has been slow recently (damn recession). Why noy? I figured I have nothing to lose.

My first step has been to create the site. Flash game license do a great little product called 'Portal in a Box'. I was tempted to customise that, but it runs from a feed from their site and I wanted more control over the look, feel and content. It's been quite challenging building it, since I have no experience in CSS, PHP or MySql. Also Working out the structure has been a 'as you go along' process. The biggest challenges have been css and sourcing the games. Doing CSS feels like trying to nail jelly to a wall. I have a look which i'm OK with, but it's not what I would have wanted and it falls apart in IE5 and 6 (I don't care). Sourcing the games. Has taken ages. I want all the games on my site to be really good (ok, I'm being more forgiving with my own games...) and downloading and formating all the games has been taking ages. PHP hasn't been that bad - I know I'm not doing it that well, but it works. PHP actually makes sense as a programming language.

At the moment I have no internet, having moved house. Just a O2 mobile dongle. When the internet is up I'll put up the new site, even if I haven't fully finished it (no search page at the moment). My traffic is so low that I don't think it will matter if it's not %100 there, and it's already better than the existing site. It will probably be up middle of next week.

If I'm doing the site seriously I'll try (and I know I've said this before) to keep this blog more updated with the games I'm working on and other info.