Flash CS3 Documentation |
|||
| ActionScript 2.0 Components Language Reference > UIObject class > UIObject.destroyObject() | |||
Flash Player 6 (6.0.79.0).
Flash MX 2004.
destroyObject(instanceName)
instanceName A string indicating the instance name of the object to be destroyed.
Nothing.
Method; destroys a component instance.
The following example removes the TextInput instance my_ti when the button is clicked. With a Button and a TextInput component in the current document's library, add the following code to the first frame of the main timeline:
//Create textinput and button instances
this.createClassObject(mx.controls.TextInput, "my_ti", 1, {text:"Hello World"});
this.createClassObject(mx.controls.Button, "my_button", 2, {label:"My Button"});
//Shift button to be below text input
my_button.move(my_ti.left, Stage.height - my_ti.bottom);
//Create Listener Object for button click
var buttonListener:Object = new Object();
buttonListener.click = function(evt_obj:Object){
destroyObject("my_ti");
}
//Add Listener
my_button.addEventListener("click", buttonListener);
Flash CS3