Removing an Item from the Display List
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.events.MouseEvent;
public class RemoveChildExample extends Sprite {
private var _label:TextField;
public function RemoveChildExample( ) {
_label = new TextField( );
_label.text = "Some Text";
addChild( _label );
stage.addEventListener( MouseEvent.CLICK, removeLabel );
}
public function removeLabel( event:MouseEvent ):void {
removeChild( _label );
}
}
}
Related examples in the same category