Actionscript 3.0 here I come!

I’m now in the process of migrating my 10 + years of Flash ActionScript knowledge to AS 3.0. I have been stuck in AS 2.0 for a while now, due to client work. I book marked a link back in 2008 that should make this process easier. Playing around in AS 3 has been a delight. The basic differences I have noticed are:

For most properties of a MovieClip, TextField, ect. have dropped the underscore.
mc._x = 10;//AS 2
mc.x = 10;//AS 3

We now use a value from 0 to 1 for various properties instead 0 to 100, so if you would like to set a value to 50% :

mc._alpha = 50;//AS 2
mc.alpha = .5;//AS 3

Strict Typing
You should of have been practicing strict typing if you were writing Object Oriented code in AS 2. Now if properties change, it will be picked up by the compiler, preventing you from creating errors and saving you hours of debugging.

public var id = 0;// AS 2
public var id:Number;// AS 3

Variable Types
There are some new variables that you should be aware of, the int and uint data types. The int type is a normal integer and uint is an unsigned integer, or a whole number whose value cannot be negative. Avoid the uint data type, it seems to be ridiculously slow, unless of course, you have a really good reason for forcing the data type such as when using color values. My rule of thumb is to use ints where they make sense, and Number whenever you are not sure.
The Void type has changed in AS3 to be lowercase (void not Void) and there’s a new data type, the asterisk* data type that is used to represent any data type or an untyped variable:
var foo:*
The * type should be used instead of omitting typing information for your variables. The XML type is now defined as a XMLObject which now references the new E4X-based XML object.

Display Objects
Display Objects are objects that can be seen on screen or added to the display list. Here’s a list:

  • MovieClip – has a timeline or frames
  • Sprite – light-weight MovieClip with no frames.
  • Shape – an object on stage with no mouse or keyboard interactivity like a vector graphic.
  • MorphShape – shape tweens created in the timeline, you cannot create them via AS but you can access them
  • TextField – textfield
  • Bitmap – a bitmap image
  • Loader – a container to load content like images and swf’s.
  • The display object solves earlier flash issues like depth management and memory optimization.

    We now exclusively use the EventDisptacher classes, so onEnterFrame, onRelease, onRollOut, ect are GONE! and we no longer have to worry about scoping issues. You can assign about any event to just about any DisplayObject.

    package {

    import flash.display.Sprite;

    public class TheDispatcher extends Sprite {

    public function TheDispatcher() {
    addEventListener(“customEvent”, handleEvent);
    dispatchEvent(new Event(“customEvent”));

    private function handleEvent(event:Event):void {

    Mouse Events
    Adobe just made our life easier.



    private function onMouseUpEvent(event:MouseEvent):void
    //call the controller.
    Here are 3 new events that I’m especially excited about:


    In AS 2 we use to create workarounds for these events which were vital to RIA development.

    In AS 3, you can now define default values for your functions.

    private function myMessage(message:String = “hello”):void


    But all optional parameters must be defined at the end of a parameter list like so:

    private function myMessage(count:Number,message:String = “foo”):void

    trace(count + ” _ ” message);


    The Dictionary Class
    The Dictionary class is a new kind of Object in AS 3. Dictionary objects use object references as its keys, or variable names. I have yet to use it but I’m sure I’ll post it once I have a real world example.

    Well that is all I have for you now, I’ll keep updating this post as things come to mind.

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    %d bloggers like this: