Wednesday, August 08, 2007

I am ramping up on AS3 finally. Will be adding notes about what I learn here.

Found some good notes from razorberry, I am copying his content here (without permission) for easy peruse...but here is the link to the original article

The Loader class doesn’t dispatch events, but Loader.contentLoaderInfo does.
If you take a look at the API documentation for Loader.load(), you’ll notice that the different events dispatched after a load operation are listed, which lead me to think that the loader itself dispatches them. The fact is that you actually need to add your event listeners to Loader.contentLoaderInfo as shown in the example on that page.

In order to use flash.utils.getDefinitionByName(), your class has to actually be compiled into the swf.
Well, duh. Flash player will throw an error if it can’t find your class. This is easily solved by including a reference to the class in your source code somewhere.
private var myClass:Class = com.package.to.MyClass;

Removing a particular item from an array is easier!
array.splice(array.indexOf(obj),1);

Copying attributes of an xml node into an object is.. different.
var o:Object = new Object();
for each (var z:XML in node.@*)
{
o[String(z.name())] = z;
}

You can check if a DisplayObject is actually attached to a display list by checking the stage property.
If the stage property is null, it isn’t attached. This might seem obvious but if you’re trying to find out why something isn’t showing up.. the reason could be that you forgot to actually attach it with addChild().

In Flex Builder’s Actionscript 3 projects, mx classes aren’t immediately available.
You need to add the mx framework.swc to the project under Project->Properties->Flex Build Path->Library Path (tab)->Add SWC.. (button). The file is located at: ${FRAMEWORKS}/libs/framework.swc.

AS3 base types don’t always default to null.
Variables of certain base types such as Boolean and int are no longer ‘undefined’ when declared. This means you can no longer perform checks such as:
if (myBoolean == undefined) doSomething(); since boolean values default to false.
You can find a list of default values on this page in the documentation.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home