ActionScript ftw’s and ftl’s
071210
In the middle of making a flash game for the scripting module, and it’s been a little frustrating. At this point, things are going to descend into a fairly massive rant so unless; a) you’re nerdy enough to understand the title to this post or b) you’d like some insight into the mind of someone who’s reasonably nerdy; you might want to give it a miss. You’ve been warned.
First of all, the good. Somewhere along the line, I decided that rather than drawing or importing them, I would generate all of the graphics in the game through code. That’s every single line, polygon, gradient and perlin noise generated cloud field. Luckily, this isn’t too hard to do in flash. I would have done the same for the sound too, but it’s a bit beyond ActionScript 2. Also, I decided that I’d be nice and object oriented by extending the MovieClip object in separate .as classes for most of my bits and pieces. As a result, my flash file has one frame with two lines of code in it (one which says stop(); and one which creates the world) and weighs in at 24KB. This pleases me. The exported swf comes out at just under 2KB so far. This also pleases me.
Things that do not please me are almost everything else to do with coding in flash. If you make a mistake in other programming languages, generally the whole thing will come grinding to a halt with a more or less helpful error message to point you in the right direction. Not flash though. If you make a mistake in flash it will either; a) do nothing, b) carry on regardless giving you no indication of where the problem is or, if you’re very lucky, c) massively fail and give you something resembling a helpful error message.
It’s also horribly inconsistent. I thought I was being clever by extending MovieClip because it gives my objects a lot of handy properties and methods (like _x or _alpha, for example) without having to write them myself. That’s all well and good, but you don’t create your new objects with new, that would be too easy. If you want them to actually appear on screen (which, of course, you do) you have to use attachMovie(). And if you do that, you can’t pass any parameters to the constructor of that object. So to get around it, you have to write an init() method for the object to take the place of the constructor, and then have the init() return the object. Which does work, but has the unpleasant side-effect of ‘causing massive rage’.
ActionScript is quite strong on the graphical side of things, which is just as well really. Unfortunately, it’s slightly lacking on the programming side of things though. Optional parameters are pretty handy; if you need to use the parameter you pass it a value, otherwise the default value gets used. ActionScript 2 doesn’t have them. Also the whole private / public thing isn’t handled all that well; it feels a little bit like flash is making it up as it goes along.
It’s a love-hate relationship.
