package { import flash.display.MovieClip; import flash.events.Event; public class BOP extends MovieClip { public function BOP() { // constructor code this.addEventListener(Event.ADDED_TO_STAGE, onADDED2STAGE); this.addEventListener(Event.ENTER_FRAME, onENTERFRAME); } private function onADDED2STAGE(event:Event):void { trace(this.parent.getChildIndex(this)); this.removeEventListener(Event.ADDED_TO_STAGE, onADDED2STAGE); } private function onENTERFRAME(event:Event):void { this.alpha -= 0.05; if (this.alpha < 0.1) { parent.removeChild(this); this.removeEventListener(Event.ENTER_FRAME, onENTERFRAME); trace( this + " HAS BEEN REMOVED " ); } } } }