Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 203

Creating and extending flex 2 components
Hide thumbs Also See for FLEX 2 - CREATING AND EXTENDING COMPONENTS:
Table of Contents

Advertisement

In the second example, you can only assign values of type
Array element is created when the application loads. The following template component
shows an alternative implementatin of the MyTemplateComponent that restricts the type of
components to be of type mx.controls.Button:
<?xml version="1.0"?>
<!-- templating/myComponents/MyTemplateComponentDeferredSpecific.mxml -->
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
initialize="init();">
<mx:Script>
<![CDATA[
import mx.containers.HBox;
import mx.core.UIComponent;
[InstanceType("mx.controls.Label")]
public var topRow:IDeferredInstance;
// Define an Array of deferred properties
// for a row of components.
// Restrict the type of the component
// to mx.controls.Button.
[InstanceType("mx.controls.Button")]
[ArrayElementType("mx.core.IDeferredInstance")]
public var bottomRow:Array;
private function init():void {
addChild(UIComponent(topRow.getInstance()));
var controlHBox:HBox = new HBox();
for (var i:int = 0; i < bottomRow.length; i++)
controlHBox.addChild(UIComponent(bottomRow[i].getInstance()));
addChild(controlHBox);
}
]]>
</mx:Script>
</mx:VBox>
mx.controls.Button
Implementing a template component
to it. Each
203

Advertisement

Table of Contents
loading

Table of Contents