We Recommend

Essential ActionScript 3.0 Essential ActionScript 3.0
The book focuses on the core language and object-oriented programming, but also adds a deep look at the centerpiece of Flash Player's new API: display programming. Enjoy hundreds of brand new pages covering exciting new language features, such as the DOM-based event architecture, E4X, and namespaces--all brimming with real-world sample code.


Posted By

chrisaiv on 02/28/08


Tagged


Versions (?)


Who likes this?

4 people have marked this snippet as a favorite

gismo
pixeldata
abdsign
palmerama


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.