View comments | RSS feed

UIObject.destroyObject()

Availability

Flash Player 6 (6.0 79.0).

Edition

Flash MX 2004.

Usage

componentInstance.destroyObject(instanceName)

Parameters

instanceName A string indicating the instance name of the object to be destroyed.

Returns

Nothing.

Description

Method; destroys a component instance.


Comments


Jarrod Castaing said on Dec 2, 2004 at 2:52 PM :
After much debugging i've found that this.getNextHighestDepth() is the problem. After a component has been put onto the stage via the Flash GUI this.getNextHighestDepth() will always trace 1048576 - even after the component is deleted.

level 1048576 is too large for destroyObject() to find but not too large for createClassObject() to create onto. If you replace this.getNextHighestDepth() with 1048576, destroyObject() will fail. However, if you decrease the number to say 104857 then it will work.

I found the best solution is to get the next depth within the movieclip in which the component is created - hence mc.getNextHighestDepth() - as only the _root is effected by this level 1048576 problem.
djtechwriter said on Apr 18, 2005 at 1:50 PM :
To clarify: you can use "this" to help manage the scope when you create/destroy components. Here is an example that destroys the TextInput instance when you click the button. Make sure you have a Button component and a TextInput component in your Library. Then, add the following 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);
No screen name said on Apr 19, 2005 at 2:04 PM :
I found that if you add the ._name property to the object, it destroys:


checks.push(CheckBox(this.createClassObject(CheckBox, "cb", ++depth, {label:tex})));

for (i = 0; i < checkCount; i++)
{
destroyObject(checks[i]._name);
}
lee_martin said on May 12, 2005 at 3:21 AM :
Have also found that this works if you add ._name. e.g.:


destroyObject(object_name._name);

Hope this helps.
jepo said on Jun 7, 2005 at 12:42 PM :
Thank you for your comments. This site is for documentation feedback only. Some comments with general questions about how to use components, bug reports, or feature requests for the Flash product, have been removed. Please use the Flash webforums for questions about how to use components: http://webforums.macromedia.com/flash. Please use this form for feature requests or suspected bugs: www.macromedia.com/support/email/wishform/.
Zal said on Jul 16, 2005 at 7:02 PM :
This documentation doesn't tell us if EventListeners are being removed with removeEventListener() before they get deleted... Or maybe it's just a stupid question, the listeners list just vahish with it...

A little more explanation here? please?
Thanks.
vitcheff said on Sep 16, 2005 at 4:11 PM :
@Zal
removeEventListener just removes the reference to the listener stored in the object, to which the listener was added.
Then you should delete the listener yourself.
This is necessary because there may be more than one component to which the listener was added, so removing it form one of them, doesn't make it unavailable for the other ones.

If you just delete the EventListener without removing it form the components, with which it's associated, a reference to it is still stored in thos components, so the its instance cannot be garbage-collected.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/mx2004/main_7_2/00002934.html