Specifications
73ADOBE FLEX 3
Building and Deploying Adobe Flex 3 Applications
}
]]></mx:Script>
<mx:Panel title="VBox with Repeater">
<mx:VBox id="myVBox" height="100" width="125" creationPolicy="none">
<mx:Button id="b1" label="Hurley"/>
<mx:Button id="b2" label="Jack"/>
<mx:Button id="b3" label="Sawyer"/>
</mx:VBox>
</mx:Panel>
<mx:Button id="myButton" click="createButtons(event)" label="Create Buttons"/>
</mx:Application>
You call methods such as createComponentFromDescriptor() and createComponentsFromDescriptor()
on the container to instantiate its children at run time. For more information on using deferred instantiation, see
“Using deferred creation” on page 94.
Destroying unused objects
Flash Player provides built-in garbage collection that frees up memory by destroying objects that are no longer
used. To ensure that the garbage collector destroys your unused objects, remove all references to that object,
including the parent’s reference to the child.
For more information about garbage collection, see “About garbage collection” on page 178 in Using Adobe Flex
Builder 3.
On containers, you can call the
removeChild() or removeChildAt() method to remove references to child
controls that are no longer needed. The following example removes references to button instances from the
myVBox control:
<?xml version="1.0"?>
<!-- optimize/DestroyObjects.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script><![CDATA[
private function destroyButtons(e:Event):void {
myVBox.removeChild(b1);
myVBox.removeChild(b2);
myVBox.removeChild(b3);
}
]]></mx:Script>
<mx:Panel title="VBox with Repeater">
<mx:VBox id="myVBox" height="100" width="125">
<mx:Button id="b1" label="Hurley"/>










