<?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"
creationComplete="breakfast.send()">
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
<mx:HTTPService id="breakfast" url="http://www.w3school.com.cn/example/xmle/simple.xml" result="breakfast_resultHandler(event)"/>
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
[Bindable]
public var food:ArrayCollection=new ArrayCollection();
protected function breakfast_resultHandler(event:ResultEvent):void
{
// TODO Auto-generated method stub
food = event.result.breakfast_menu.food as ArrayCollection;
}
]]>
</fx:Script>
<mx:DataGrid x="19" y="10" dataProvider="{food}" height="300" variableRowHeight="true" textAlign="center">
<mx:columns>
<mx:DataGridColumn headerText="Food name" dataField="name" width="150" />
<mx:DataGridColumn headerText="Price" dataField="price" width="50" />
<mx:DataGridColumn headerText="Description" dataField="description" width="250" wordWrap="true"/>
<mx:DataGridColumn headerText="Calories" dataField="calories" width="50" />
</mx:columns>
</mx:DataGrid>
<s:ComboBox x="145" y="427" dataProvider="{food}" labelField="name"/>
</s:Application>
转载于:https://www.cnblogs.com/zjhnl/archive/2011/07/26/2116966.html