Converting from AS2 to AS3
Monday, March 17th, 2008This post should help you convert from Actionscript 2.0 to 3.0. AS3, in my opinion, was the biggest jump for Adobe from Flash 8 to CS3. It’s shown to be heaps faster than AS2, with a whole new bunch of classes and features. I won’t teach you everything there is to know, this is just a small step for you if your facing this dilemma. If know nothing about AS2, don’t bother reading.
Firstly the properties are represented differently, there is no more underscore when you are setting properties:
The next thing you need to notice is that you can no longer add code to movieclips directly on the stage, all coding is now done from the timeline. Also, no more using ‘_root’.
If you are not already into defining variables or classes properly, AS3 forces you to do this or an error occurs. This is the correct format:
A big difference in AS3 for game development is the use of event listeners. Now, instead of calling a function like ‘onEnterFrame’, you create a custom function that will execute on the event, then add an event listener to the MC you want the event to listen to. Here’s a quick example with the enter frame event: (more…)
