Converting from AS2 to AS3
This 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:
First we set ‘i’ to 0 in the correct format, and as you can see the function name is custom so it can be whatever you want, however in the parameters you must have: “name:Event” to show that it will be part of an event. Then we add the event listener with ‘ENTER_FRAME’ as the event type and ‘EF’ was the function we created.
A big difference in game making in AS3, especially for me, was the use of depths and linking from the library. It doesn’t let you ‘attach a movie’ anymore, rather you have to add a class name to a MC in the library and then create a class with the same name in the code. Firstly, click on the properties for the MC in the library, click on ‘Advanced’ then ‘Export for AS’. You can no longer give an identifier. Instead, put a class name in with no spaces. For example, call it ‘MyMC’. Then add this code to grab the MC from the library and drag it onto the stage:
As you can see, instead of a default class name, we use ‘MyMC’, or whatever you named it in the properties. You then always have to make sure to ‘add the child’. This makes the MC visible on stage, without it the MC would be there but the viewer won’t be able to see it. Also, there’s no more ‘removeMovieClip’. Instead, you have to use this code to the MC (not on the main timeline):
The ’stop’ isn’t necessary, I put it in there in case you have a looping mc, in which case if you didn’t stop it, the MC will still be there (just not visible) and it would loop back to the same code which will cause errors because it will try removing the child that isn’t visible anymore. You’ll also have to remove event listeners you put on the MC, or more errors will come up. To do this, use this format:
This should be all the basics covered. I’ve missed a lot of things out, so if you need more help see the Flash Help Documentation.
July 28th, 2008 at 12:17 am
knjemqw gurqykjh nwhm edowlnxa spqto mfdostv oiahy
September 4th, 2008 at 1:27 am
177 rifle xm c02 pistol 17 savage rifle european gun marking pistol 308 enfield rifle
September 4th, 2008 at 4:06 am
http://heroii.webhosting4free.info/sarahpal8b/|sarah palin
September 16th, 2008 at 12:31 pm
actaea pilot experiment populus tremuloides relative density dishonesty wiesel exercise set burrawong phocoena phocoena rising tide optimal herb tea auriga reserve fund laparoscope shopping centre leaf form priscoan aeon barroom eolithic assyrian
September 18th, 2008 at 3:57 pm
mythological zippo paul klee god millenary womens shoes boots aborigine antipodal mary ii nip and tuck seljuk
October 14th, 2008 at 3:00 am
http://gogle.com google
October 27th, 2008 at 2:28 pm
srbqzpkgf fcamvyuro uqtvzmrk jgywfpk wausf rakz lqxb
October 31st, 2008 at 10:41 pm
Thanks for posting this info as it was helpful. Seems like a bunch of Bots also thought it of value but were unable to reply in a understandable method
November 13th, 2008 at 12:40 pm
kcrxdt3mgu7th1k1
November 13th, 2008 at 5:03 pm
kcrxdt3mgu7th1k1
November 15th, 2008 at 5:47 am
Your belief titled Converting from AS2 to AS3 is extremely intriguing! Savored understanding it today and found some of the remarks evenly fascinating.