• 【设为首页】
  • 【收藏闪客居】
当前位置:主页>Flex>文章内容
  • Flex 3处理外部XML的两种方式
  • 来源:flashxm.com 作者:flashxm 2008-06-29 【

其一,用mx:Model:

  1. <?xml version="1.0"?>
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
  3.     <mx:Model id="catalogService" source="catalog.xml" />
  4.     <mx:ArrayCollection id="myXC" source="{catalogService.product}"/>
  5.     <mx:Repeater id="r" dataProvider="{myXC}" startingIndex="1">
  6.         <mx:RadioButton id="Radio" label="{r.currentItem.name}"/>
  7.     </mx:Repeater>
  8. </mx:Application>

其二:用mx:HTTPService:

  1. <?xml version="1.0"?>
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" initialize="catalogService.send()">
  3.     <mx:HTTPService id="catalogService" url="catalog.xml" resultFormat="e4x"/>
  4.     <mx:XMLListCollection id="myXC" source="{catalogService.lastResult.product}"/>
  5.     <mx:Repeater id="r" dataProvider="{myXC}" startingIndex="1">
  6.         <mx:RadioButton id="Radio" label="{r.currentItem.name}"/>
  7.     </mx:Repeater>
  8. </mx:Application>

其中,XML数据如下:

  1. <?xml version="1.0"?>
  2. <products>
  3.   <product>
  4.     <name>Name</name>
  5.     <price>Price</price>
  6.     <freeship>Free Shipping?</freeship>
  7.   </product>
  8.   <product>
  9.     <name>Whirlygig</name>
  10.     <price>5</price>
  11.     <freeship>false</freeship>
  12.   </product>
  13.   <product>
  14.     <name>Tilty Thingy</name>
  15.     <price>15</price>
  16.     <freeship>true</freeship>
  17.   </product>
  18. <product>
  19.     <name>Really Big Blocks</name>
  20.     <price>25</price>
  21.     <freeship>true</freeship>
  22.   </product>
  23. </products>

请注意数据集的细微差别。




上一篇:Flex beta2+XFire开发实例   下一篇:用免费Flex3 SDK开发flash10应用
  • 用户名:新注册) 密码: 匿名评论
  • 评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规)


FLASH源文件

Copyright © 2006-2008 flashas.net All Rights Reserved.
网站内容咨询: admin#flashas.net (#为@) 联系QQ:40777822 浙ICP备06033001号
(本网站最佳浏览解析度为1024*768, 建议使用IE 6.0或以上版本浏览器。)