我有这个XMLList:
<fx:XMLList id="Generic List" xmlns="">
<menuitem label="First entry" url="www.aaa.com"/>
<menuitem label="Second entry" url="www.bbb.com"/>
<menuitem label="Third Entry" url="www.ccc.com"/>
</fx:XMLList>我想在我的组合框(代码不显示)中随机选择这些菜单项中的一个。我使用的是Flex Builder 4,6。
谢谢你的帮助。
发布于 2013-02-09 03:51:45
试试这个:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Declarations>
<fx:XMLList id="genericList" xmlns="">
<menuitem label="First entry" url="www.aaa.com"/>
<menuitem label="Second entry" url="www.bbb.com"/>
<menuitem label="Third Entry" url="www.ccc.com"/>
</fx:XMLList>
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.XMLListCollection;
]]>
</fx:Script>
<s:ComboBox
id="cbEntry"
dataProvider="{new XMLListCollection(genericList)}"
labelField="@label"
creationComplete="{cbEntry.selectedIndex = Math.floor(cbEntry.dataProvider.length * Math.random());}"/>
</s:Application>https://stackoverflow.com/questions/14778499
复制相似问题