我花了好几个小时试图弄明白......任何帮助都会非常感激!!!
我有一个ArrayCollection被读取以编程方式生成手风琴中的容器:
<s:ArrayCollection id="_ac_ps">
<fx:Object label="Block and lot" data="_blocklot" searchType="districtblocklot" info="" />
<fx:Object label="Address" data="_address" searchType="singletxtstring" info=""/>
<fx:Object label="Owner name" data="_owner" searchType="singletxtstring" info=""/>
<fx:Object label="Advanced data mining" data="_advanced" searchType="advancedmining" info=""/>
</s:ArrayCollection>
这就是我生成手风琴儿童的方式:
for (var num1:int = 0; num1 <= _ac_ps.length - 1; num1++)
{
navContent = new NavigatorContent();
navContent.percentWidth = 100;
navContent.percentHeight = 100;
navContent.label = _ac_ps[num1].label;
navContent.id = ""+_ac_ps[num1].data;
navContent.name = ""+_ac_ps[num1].data;
////(""+navContent.id);
_searchAccordion.addChild(navContent);
}
这很好用。现在我要做的是根据手风琴中导航器内容的id,添加孩子。例如,我想将一个类型为Label的子元素添加到navigatorContent中,其id为“_blocklot”,但是将一个textInput框添加到navigatorContent对象中,其id为“_address”。
private function loadSearchControls( ):void
{
var accordionChildren:Array = _searchAccordion.getChildren();
for each(var currentnavContent:NavigatorContent in accordionChildren)
{
Alert.show (""+currentnavContent.id, "currentnavContent.id");
if (currentnavContent.id == "_blocklot")
{
try{
var _label:Label = new Label();
_label.text = "come on now!!!!!!";
//SO HOW DO I CAPTURE THE ID SO THAT I CAN ADD THIS LABEL AS A CHILD???
//_searchAccordion._blocklot.addChild(_label); does not work
}
catch(errorObj:Error)
{
Alert.show("nope");
}
}
else if (currentnavContent.id == "_address" )
{
Alert.show("bbb");
}
}
答案 0 :(得分:0)
这对你有用。您已经确定currentNavContent是否是您想要的,所以只需将控件添加到currentNavContent。
private function loadSearchControls(event:MouseEvent):void
{
var accordionChildren:Array = _searchAccordion.getChildren();
for each(var currentnavContent:NavigatorContent in accordionChildren)
{
Alert.show (""+currentnavContent.id, "currentnavContent.id");
if (currentnavContent.id == "_blocklot")
{
try{
var _label:Label = new Label();
_label.text = "come on now!!!!!!";
//SO HOW DO I CAPTURE THE ID SO THAT I CAN ADD THIS LABEL AS A CHILD???
//_searchAccordion._blocklot.addChild(_label); does not work
currentnavContent.addElement(_label);
}
catch(errorObj:Error)
{
Alert.show("nope");
}
}
else if (currentnavContent.id == "_address" )
{
Alert.show("bbb");
}
}
}