Specifications
75ADOBE FLEX 3
Building and Deploying Adobe Flex 3 Applications
</mx:Panel>
<mx:Button id="myButton" click="destroyButtons(event)" label="Destroy Buttons"/>
</mx:Application>
You cannot call the removeEventListener() method on an event handler that you added inline. In the following
example, you cannot call
removeEventListener() on b1’s click event handler, but you can call it on b2’s and
b3’s event handlers:
<?xml version="1.0"?>
<!-- optimize/RemoveSomeListeners.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="initApp(event)">
<mx:Script><![CDATA[
private function initApp(e:Event):void {
b2.addEventListener("click",myClickHandler);
b3.addEventListener("click",myClickHandler);
}
private function destroyButtons(e:Event):void {
b2.removeEventListener("click",myClickHandler);
b3.removeEventListener("click",myClickHandler);
myVBox.removeChild(b1);
myVBox.removeChild(b2);
myVBox.removeChild(b3);
}
private function myClickHandler(e:Event):void {
// Do something here.
}
]]></mx:Script>
<mx:Panel title="VBox with Repeater">
<mx:VBox id="myVBox" height="100" width="125">
<mx:Button id="b1" label="Hurley" click="myClickHandler(event)"/>
<mx:Button id="b2" label="Jack"/>
<mx:Button id="b3" label="Sawyer"/>
</mx:VBox>
</mx:Panel>
<mx:Button id="myButton" click="destroyButtons(event)" label="Destroy Buttons"/>
</mx:Application>










