Archive for October 26th, 2007

AS3 : Display programming and Event Listeners

October 26, 2007

My study of “Essential Actionscript 3.0 ” continues…

To reduce memory and processor usage, event listeners should always be unregistered when they are no longer needed in a program.
For eventListeners registered to the ancestor of the display objects :
event.currentTarget : refers to the display object’s ancestor
event.target : refers to the actual object,which trigered the event

Dispatching a new custom event in Actionscript is as simple as extending the EventDispatcher class, giving the new event a name, and invoking the EventDispatcher class’s instance method dispatchEvent();
The object on which dispatchEvent() is invoked is the event target.

Display objects :
addChild() : adds a display object to the Application’s Main swf ( displayObj.root returns the Main Application Object )
stage.addChild(): adds a display object to the stage ( displayObj.root returns the Stage Object )