Posted By

chrisaiv on 02/28/08


Tagged

as3 stage


Versions (?)

Who likes this?

6 people have marked this snippet as a favorite

gismo
pixeldata
abdsign
palmerama
THEPWN3R
tspitzr


AS3: onAdded Event Listener


 / Published in: ActionScript 3
 

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

  1. function onAdded(e:Event):void {
  2. // get reference to child from event object
  3. // as child variable of target will not yet be defined
  4. var childRef:MovieClip = e.target as MovieClip;
  5. trace(childRef.type + " " + stage.numChildren);
  6.  
  7. // check the name of the reference for correct instance name
  8. if (childRef && childRef.name == "child"){
  9. e.target.removeEventListener(Event.ADDED, onAdded);
  10. }
  11. }
  12. //stage.addEventListener(Event.ADDED, onAdded);

Report this snippet  

You need to login to post a comment.