点击这里使用RSS订阅本Blog:
其一,用mx:Model:
- <?xml version="1.0"?>
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
- <mx:Model id="catalogService" source="catalog.xml" />
- <mx:ArrayCollection id="myXC" source="{catalogService.product}"/>
- <mx:Repeater id="r" dataProvider="{myXC}" startingIndex="1">
- <mx:RadioButton id="Radio" label="{r.currentItem.name}"/>
- </mx:Repeater>
- </mx:Application>
其二:用mx:HTTPService:
- <?xml version="1.0"?>
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" initialize="catalogService.send()">
- <mx:HTTPService id="catalogService" url="catalog.xml" resultFormat="e4x"/>
- <mx:XMLListCollection id="myXC" source="{catalogService.lastResult.product}"/>
- <mx:Repeater id="r" dataProvider="{myXC}" startingIndex="1">
- <mx:RadioButton id="Radio" label="{r.currentItem.name}"/>
- </mx:Repeater>
- </mx:Application>
其中,XML数据如下:
- <?xml version="1.0"?>
- <products>
- <product>
- <name>Name</name>
- <price>Price</price>
- <freeship>Free Shipping?</freeship>
- </product>
- <product>
- <name>Whirlygig</name>
- <price>5</price>
- <freeship>false</freeship>
- </product>
- <product>
- <name>Tilty Thingy</name>
- <price>15</price>
- <freeship>true</freeship>
- </product>
- <product>
- <name>Really Big Blocks</name>
- <price>25</price>
- <freeship>true</freeship>
- </product>
- </products>
请注意数据集的细微差别。
摘自【http://www.5uflash.com/Flex-AIR/flexziliao/list_17_2.html】

本文介绍了两种在Flex中加载和显示XML数据的方法:使用mx:Model和mx:HTTPService组件。通过实例展示了如何配置这些组件并将其与UI元素关联,以便在界面上呈现数据。

被折叠的 条评论
为什么被折叠?



