<mx:Repeater id="rep" dataProvider="{headingData.component}">
<mx:HBox id="panel" label="{rep.currentItem.title}"
width="100%" height="100%">
</mx:HBox>
</mx:Repeater>
protected function creationCompleteHandler():void
{
//Alert.show("init2");
var components:Array = getComponentsFromXML(xml.component);
var i:int = 0;
var n:int = components.length;
for (i; i < n; i++)
{
panel.addChild(components[i] as DisplayObject);
}
}
When i am not placing it under a repeater tag, the components are created from XML, but if i do then the components are not getting created.
Any issues.
<components type="array">
<component type="mx.controls::ComboBox" title="Title One" description="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum." width="230" height="220">
<link linkname="Option one"/>
<link linkname="Option Two"/>
</component开发者_StackOverflow中文版>
<component type="mx.controls::RadioButton" title="Title Two" width="230" description="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.">
<link linkname="Option one"/>
<link linkname="Option Two"/>
</component>
<component type="mx.controls::RadioButton" title="Title Three" width="230" description="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.">
<link linkname="Option one"/>
</component>
<component type="mx.controls::CheckBox" title="Title Four" width="230" description="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum." height="220">
<link linkname="Option one"/>
<link linkname="Option Two"/>
<link linkname="Option Three"/>
</component>
<component type="mx.controls::RadioButton" title="Title Five" width="230" description="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum." height="220">
<link linkname="Option one"/>
<link linkname="Option Two"/>
<link linkname="Option Three"/>
</component>
</components>
Ok, the problem is that the id='panel'
inside the Repeater works a bit different than normally. Because this components can be repeated, if you could just set the id, it would be the same for all of them. That's why the name (in your case panel
) is actually an array (in this case an array of HBoxes).
If you want to add the child to the first one you need to choose the first array element -
panel[0].addChild(components[i] as DisplayObject);
Do you need many HBox's or many components in it? Usually a Repeater is not used for nested things like in your example. Also, you shouldn't set the 'id' property of your Repeater's child. If you need a complex component you should inherit from HBox and paste that as3 code into it.
Probably, you have to wrap Repeater into HBox. Then you shouldn't add your items into the panel. They should be specified in Repeater's dataProvider.
精彩评论