Deleting DisplayObject Instances in Adobe AIR
I just have a query on deleting displayobject instance. Let me elaborate on this:
I had created a custom component called ‘PanelItem’ (which basically contains a Text Area and a close button in a Panel container) Then in the main.mxml, I had utilized the above custom component as follows:
var tempPanel: PanelItem = new PanelItem();
Subsequently assigned values for its attributes such as x,y, width, height and id for tempPanel and then added child instances as below addChild(tempPanel);
The above code displays one instance of the custom displayobject. My problem is that when the ‘close’ button on the panel is clicked, I want the displayobject instance to be removed 开发者_C百科from the memory.
To do the ‘close’ action, I had added the following to the code
tempPanel.removAllChildren();
tempPanel.visible = false;
But the above only removes the children of displayobject and the doesnot removes the displayobject instance completely from memory. I read somewhere I need to ‘delete’ the displayobject, but could not find any reference to the same in the help file
Any thoughts on how do I go about removing the displayobject completely from memory?
Anther question I have is, if I had invoked multiple instances of tempPanel, how do I get a count of the number of instances.
TempPanel.numChildren() only returns the number of child instance (which got invoked thru addChild method) and not the actual numbers of displayobjects floating around.
Any help on the above will be much appreciated.
Thanks Srinivasan S
you could extend from CasaSprite (http://as3.casalib.org/docs/org_casalib_display_CasaSprite.html) which has a destroy function.
精彩评论