topical media & game development
professional-flex-code-18-DeferringComponents.mx
professional-flex-code-18-DeferringComponents.mx
[swf]
flex
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.core.ComponentDescriptor;
private function createComponents(event:Event):void
{
CONTAINER.createComponentsFromDescriptors();
for(var i:int = 0 ; i < CONTAINER.childDescriptors.length; i++)
{
var mDescriptor:ComponentDescriptor = CONTAINER.childDescriptors[i];
var mObj:Object = mDescriptor.properties;
TEXTAREA.text += String("ID:"+ mDescriptor.id +"\nTYPE:"+ mDescriptor.type +"\n");
for(var j:String in mObj)
{
TEXTAREA.text += String("PROPERTY "+ j +"= "+ mObj[j] +"\n");
}
TEXTAREA.text += String("-------------\n");
}
}
private function componentCreationHandler(event:Event):void {
TEXTAREA.text += String("NOTE: creationComplete on "+event.target.id+" was called\n");
}
]]>
</mx:Script>
<mx:Button label="CREATE COMPONENTS" click="createComponents(event);" />
<mx:HBox id="CONTAINER" creationPolicy="none" creationComplete="componentCreationHandler(event)">
<mx:Button id="ADDED_BUTTON_1"
label="BUTTON COMPONENT 01"
alpha=".5"
creationComplete="componentCreationHandler(event)"/>
<mx:Button id="ADDED_BUTTON_2"
label="BUTTON COMPONENT 02"
alpha=".3"
creationComplete="componentCreationHandler(event)"/>
<mx:Button id="ADDED_BUTTON_3"
label="BUTTON COMPONENT 03"
alpha=".2"
creationComplete="componentCreationHandler(event)"/>
</mx:HBox>
<mx:TextArea id="TEXTAREA" width="350" height="300" />
</mx:Application>
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.