I recently worked on a project for IFBIN where I created the same example in both AS2 and AS3. It’s an interesting experience, and I wanted to get my thoughts down about it.
-
Build everything in AS3 first. It’s a stricter language, and if you’re anything like me, if start out in AS2, you’ll probably take a few shortcuts. You’ll pay once you get to the AS3 version. In my case, I found it more important to write good code because it’s is going to be viewed by a lot of people.
-
You’ll hit some problems if you’re using components. Obviously, the components in Flash 8 and Flex 2 aren’t the same. DataProviders for Lists and DataGrids don’t work in quite the same way (Array for Flash 8 versus ArrayCollection in Flex 2). Likewise, text components don’t always work the same in regards to HTML.
-
AS2 events suck. Built-in classes like XML don’t really dispatch events, and events in components need things like Delegate. Whether you start with AS2 or AS3, if you use any native events, you’re going to have to rewrite some code.
-
AS3 uses the lowercase
void
instead of the uppercaseVoid
-
For-loops in AS3 should use the new integer type
int
instead ofNumber
. It’s not required, but a good best practice. -
XML is handled differently. In AS3, you’ll probably want to use the new E4X. If you’re interested, AS3 provides a legacy class to match the XML class in AS2.
A lot of classes moved around too. Check out the AS2 to AS3 migration guide for complete details. Can anyone think of other differences that someone should consider when developing for both platforms?
Bleh. E4X is confusing, and about as readable is firstChild.firstChild… I’ll stick to old XML. It’s faster than E4X anyway. Agree with everything else, though. I started in AS2, so ran into the porting issues. Still, AS2 was faster to develop in, but not debug.
Hi,
i m updating my e-learning course player project with Flash cs3 and AS3.0. the old version of course player was in As2.0. which load cousre swf files .
it was working fine Flash8 As2.0.
the player load course swf. the loaded course swf on a specifec frame call a method like this
_level0.setButton(2) method from course player;
The setButton(parameter) method defination is in new courser player. the loaded movie which is in Actionscritp2.0 not finding this method
in new course player which in Actionscript3.0. its working well with the old course player.
can any one give me solution to solve the issue.
i can’t make changes in course swf files b/c there are thousand of course files
shane, AS2 and AS3 cannot communicate directly like that. If you want to communicate between your SWFs with different languages, you’ll need to use
LocalConnection
, but that will require changing your course SWFs. You may simply need to stay in AS2 for this system.