Return to Snippet

Revision: 5346
at February 28, 2008 13:08 by chrisaiv


Initial Code
function onAdded(e:Event):void {
    // get reference to child from event object
    // as child variable of target will not yet be defined
    var childRef:MovieClip = e.target as MovieClip;
	trace(childRef.type + " " + stage.numChildren);
   
    // check the name of the reference for correct instance name
    if (childRef && childRef.name == "child"){
        e.target.removeEventListener(Event.ADDED, onAdded);
    }
}
//stage.addEventListener(Event.ADDED, onAdded);

Initial URL

                                

Initial Description
The point of this listener is to detect when something has been added to the stage.  Purely experimental.

Initial Title
AS3: onAdded Event Listener

Initial Tags

                                

Initial Language
ActionScript 3