Search Flex Components Free

Custom Search

December 27, 2007

Adding Dynamic UI Elements in Flex

Creat a New mxml file:

DynamicComponent.mxml

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”
http://www.adobe.com/2006/mxml ” xmlns=”*” backgroundColor=”white”>
<mx:Script>
<![CDATA[
public function createBarsToo():void {
myHBox.addChild(new CustomComponent());
}
]]>
</mx:Script>
<mx:HBox id=”myHBox” horizontalGap=”3″ backgroundColor=”red” width=”150″ height=”50″/>
<mx:Button id=”myButtonToo” click=”createBarsToo()” label=”Create Component”/>
</mx:Application>

CustomComponent.mxml
<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Canvas xmlns:mx=”
http://www.adobe.com/2006/mxml ” xmlns=”*” backgroundColor=”blue” cornerRadius=”5″ width=”10″ borderStyle=”inset” height=”50″/>

Related Flex Tutorials