I couldn’t take the Flex class at LA Flash this weekend ($$$), but I did manage to treat that envy-induced tic in my eye by downloading Flex Builder 2 and monkeying around with AS3 for a while.
First impressions: It may be true that AS3 takes actionscript to a new level or performance and programmer- and application-friendly logic…but for the practicing actionscripter, the hype is misleading…
For one, when it’s compiled to bytecode, AS3 might be an alien beast, but the difference between AS3 and AS2 is minimal (reshuffled, expanded API, stricter typing, runtime errors, additional data types, packages), and nearly negligible when compared to the difference between AS2 and AS1 (classes!, typing!, standard inheritance!).
For two, AS3 is not some souped-up, sophisticated version of AS2–it’s actually simpler and easier (this goes even more for Flex (my last post), which is astoundingly, even alarmingly simple):
clip:MovieClip=new MovieClip()
Wasn’t that easy? Want to put this clip in another clip?
otherClip.addChild(clip)
Want to control the depth more precisely?
otherClip.addChildAt(clip, 3)
The new XML classes allow you to access XML data by strings/names:
userXML.colorPref
This returns the color preference for a user. Anyone nostalgic for firstChild.firstChild.childNodes[someDamnIndex]?
Another aspect of AS2 you will not miss is explicit delegation.
clip. addEventListener(MouseEvent.MouseDown, callbackFunction)
function callbackFunction() {
//in here, “this” is automatically scoped to where the listener is added…
//your neatly centralized code, that is
}
A class I’m especially interested in is Loader:
myLoader=new Loader()
myLoader.load(new URLRequest(”here/here/this.ext”))
Unlike MovieClipLoader, this class can load pics and swfs without putting them anywhere–they just hang out in the memory, waiting to be used (though how to access them, I’m not sure.)
If you are comfortable with AS2, the only thing that might initially throw you is the display API.
MovieClip no longer has its distorting prominence in AS3; it’s one among many display objects (shapes, bitmaps, texts) that can be mixed and matched.
My guess is that this new API–and the others–will be easy to learn and remember because they are logical and meaningful (where are video, sound and camera?…in flash.media, of course) rather than the arbitrary result of Actionscript’s evolution.
In sum: Adobe has cleaned up their desktop and put the language in clearly labelled, tidy little folders.
[Edit: After becoming comfortable with AS3, I definitely stand by these initial judgments. But after hearing–again and again–silly, self-serving proclamations from developers about how AS3 will separate the boys from the men in terms of coding, let me make a distinction. IF you are already using AS2-type variable typing and classes, you will NOT find the transition to AS3 difficult. If you are stuck on AS1-type coding, it will be difficult to ratchet up your coding, but even in this case, it will be MORE difficult to learn AS2 than AS3…so if you are making the leap, skip AS2 and go right for the gusto–AS3.]
Tags: code3 Comments
3 responses so far ↓
Thanks for the run-down. Nice and easy to understand.
Thanks, got to know what AS3 is gonna be like.
“this class can load pics and swfs without putting them anywhere–they just hang out in the memory, waiting to be used (though how to access them, Iã€m not sure.)”
using the addChild as well :)
otherClip.addChild(myLoader)