Remove element at location
<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 addFirstElement():void
{
myContent.addElementAt( getNewElement(), 0 );
}
private function removeFirstElement():void
{
if( myContent.numElements > 0 )
myContent.removeElement( myContent.getElementAt( 0 ) );
}
private function removeLastElement():void
{
if( myContent.numElements > 0 )
myContent.removeElementAt( myContent.numElements - 1 );
}
</mx:Script>
<mx:Button label="addFirst" click="addFirstElement();" />
<mx:Button label="removeFirst" click="removeFirstElement()" />
<mx:Button label="removeLast" click="removeLastElement()" />
<mx:Button label="removeAll" click="myContent.removeAllElements()" />
<mx:VBox id="myContent">
</mx:VBox>
</mx:Application>
Related examples in the same category