我有一个看起来像这样的火花形式。我正在尝试遍历表单并将每个 DropDownList 的 id 推送到一个数组中。
我能够成功地找出表单项的 ID。但是我无法使用任何用于访问子项的方法来获取 DropDownList 的 ID,我使用的是 Flex 3。我是新的 Flex 4,经过一些阅读,我理解它是由于与 spark 架构相关的东西。
这是形式。
<s:Form id="facilities" x="51" y="32" width="595" height="402">
<s:FormHeading label="SWOT ANALYSIS FORMAT FOR PLOT PURCHASE" fontSize="15">
</s:FormHeading>
<s:FormItem id = "petrolPumpsFormItem" required="true" width="464" label="Petrol Pumps:">
<s:DropDownList id = "petrolPumps" width="220" prompt="Select distance from the plot" labelField="distance" >
<s:dataProvider>
<s:ArrayCollection>
<fx:Object distance="1-3 km" mark="100"/>
<fx:Object distance="3-6 km" mark="90"/>
<fx:Object distance="6-9 km" mark="80"/>
<fx:Object distance="9-12 km" mark="70"/>
<fx:Object distance="12-15 km" mark="60"/>
<fx:Object distance="15-18 km" mark="50"/>
</s:ArrayCollection>
</s:dataProvider>
</s:DropDownList>
</s:FormItem>
<s:FormItem id="filmTheatreFormItem" required="true" width="464" label="Film Theatre:">
<s:DropDownList id="filmTheatre" width="220" prompt="Select distance from the plot" labelField="distance" >
<s:dataProvider>
<s:ArrayCollection>
<fx:Object distance="1-3 km" mark="100"/>
<fx:Object distance="3-6 km" mark="90"/>
<fx:Object distance="6-9 km" mark="80"/>
<fx:Object distance="9-12 km" mark="70"/>
<fx:Object distance="12-15 km" mark="60"/>
<fx:Object distance="15-18 km" mark="50"/>
</s:ArrayCollection>
</s:dataProvider>
</s:DropDownList>
</s:FormItem>
<s:FormItem id= "atmFormItem" required="true" width="464" label="ATM:">
<s:DropDownList id= "atm" width="220" prompt="Select distance from the plot" labelField="distance" >
<s:dataProvider>
<s:ArrayCollection>
<fx:Object distance="1-3 km" mark="100"/>
<fx:Object distance="3-6 km" mark="90"/>
<fx:Object distance="6-9 km" mark="80"/>
<fx:Object distance="9-12 km" mark="70"/>
<fx:Object distance="12-15 km" mark="60"/>
<fx:Object distance="15-18 km" mark="50"/>
</s:ArrayCollection>
</s:dataProvider>
</s:DropDownList>
</s:FormItem>
</s:Form>
我可以像这样访问表单项。“设施”是表格的名称。
for (var i:int = 0 ;i <= facilities.numElements-1;i++)
{
var item:IVisualElementContainer = facilities.getElementAt(i) as IVisualElementContainer;
trace(item);
}
我尝试了这个链接http://www.igorcosta.org/?p=366并尝试使用那里给出的类。
问题是抛出了一个错误。Flash builder 将我带到该代码内第二个函数中的第二个 for 循环,并显示在那里使用的 item.numElements 造成了问题。我试图在我的代码中使用 item.numElements(上面显示的那个我用来追踪 FormItem id),但它也不起作用。有人有任何线索吗?