小小菜鸟的web菜园子

web开发学习。好记性不如烂笔头。每天进步一点点!

导航

FLEX如何读取XML文件.

FLEX读取XML文件实例教程.

XML文件:
<?xml version=”1.0″?>
<books>
<item>
<title>The Complete Guide to Flex 2 and ActionScript 3.0</title>
</item>
<item>
<title>Programming Flex 2 (Programming)</title>
</item>
<item>
<title>Adobe Flex 2: Training from the Source</title>
</item>
</books>


MXML文件:
<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute”
initialize=”myService.send()”>
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;

[Bindable]
private var myData:ArrayCollection;

private function resultHandler(event:ResultEvent):void {
myData = event.result.books.item;

}

]]>
</mx:Script>

<mx:HTTPService id=”myService”
url=”books.xml”
result=”resultHandler(event)”/>

<mx:Text id=”something” text=”{myData.getItemAt(0).title}”/>

</mx:Application>

posted on 2008-05-15 16:34  『小小菜鸟』  阅读(8185)  评论(0编辑  收藏  举报