Mega Code Archive

 
Categories / Flex / Container
 

Remove all elements

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:s="library://ns.adobe.com/flex/spark">     <mx:Script>                      import mx.core.IVisualElement;             import spark.components.Button;                          private function getNewElement():IVisualElement             {                 var btn:spark.components.Button = new spark.components.Button();                 btn.label = "button " + myContent.numElements;                 return btn;             }             private function addLastElement():void             {                 myContent.addElement( getNewElement() );             }                          private function removeFirstElement():void             {                 if( myContent.numElements > 0 )                     myContent.removeElement( myContent.getElementAt( 0 ) );             }                         </mx:Script>     <mx:Button label="addLast" click="addLastElement();" />     <mx:Button label="removeFirst" click="removeFirstElement()" />     <mx:Button label="removeAll" click="myContent.removeAllElements()" />          <mx:VBox id="myContent">     </mx:VBox>      </mx:Application>