Saturday, 28 July 2007

Close, but no...


So I sat down today to do some coding with Flash 9 (CS3) in AS3 on my Power Mac G5. I'm used to using AS2 and have a very good understanding of Object Oriented Programming, software architecture and design patterns and have been looking forward to implementing some of the cool features of OOP that aren't in AS2 in a Flash game. I have been working on a space game but recently started to lose enthusiasm for it because the idea of it isn't really mine, it's a remake of the old classic Elite but in Flash as 2d. Anyway, it would be nice to work on something that is totally my idea and I figure I can combine that with dabbling in AS3.

To bring you up to scratch with where I'm at, a work colleague of mine (a.k.a the Schoolboy Coder) wanted to trap an event that Flash doesn't provide. The textfield object will send an event when text is changed by the user when typing text into it, but not when the text is changed by code. He came to me to ask for ideas on solving it and of course I suggested extending the textfield class and sending a custom event out in the text set method. This is a the usual OOP solution to getting more functionality out of a class. This works fine, however, because Flash 8 / AS 2 do not support the creation of custom extended text fields on the stage, and there is no way to link one on the stage with your custom class, this solution (while it works in code) does not work with a real textfield. So I'm starting to brush up against some of the limitations of Actionscript 2. (As an aside, he eventually solved it using another suggestion of mine, adding a new method to the textfield class using prototype after trying without much success to create a proxy [think, decorator pattern], but then hes not as experienced a coder and also prototype is quite a simple, neat and tidy solution).

So hitting the limits of AS 2 pushes me onto dabbling with AS 3 and while I'm liking the new additions, where is the rest of the OOP spec? After only one morning I'm wondering what the hell happened to Adobe implementing function overloading? I can get around this by using a default constructor but hey its a feature that is glaring by its omission. What the hell happened to private constructors? I could use them in AS 2! And why are there still no typed arrays? That is surely a basic one for the Flash team to add in!

No comments: