topical media & game development
professional-flex-code-18-DeferringComponents_2.mx
professional-flex-code-18-DeferringComponents_2.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 var count:int = 0;
private function createComponent(event:Event):void
{
CONTAINER.createComponentFromDescriptor(CONTAINER.childDescriptors[count], true);
CONTAINER.validateNow();
var mDescriptor:ComponentDescriptor = CONTAINER.childDescriptors[count];
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");
if(count < CONTAINER.childDescriptors.length - 1) {
count++;
} else {
CREATE_COMPONENTS_BUTTON.alpha = .1;
CREATE_COMPONENTS_BUTTON.enabled = false;
}
}
private function componentCreationHandler(event:Event):void {
TEXTAREA.text += String("NOTE: creationComplete on "+event.target.id+" was called\n");
}
]]>
</mx:Script>
<mx:Button id="CREATE_COMPONENTS_BUTTON" label="CREATE COMPONENTS" click="createComponent(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.