v1_11 从服务取得XML数据
v1_11 Requesting and retrieving XMLdata from the server? flex从服务取得XML数据ex1_04?1.不是所有的mxml components是可见的使用fx:Declarations来声明不可见的对象
<fx:Declarations><!-- 将非可视元素(例如服务、值对象)放在此处 --></fx:Declarations>??2.flex从远程服务获取数据的三种方式?? HttpService?? WebService?? RemoteObject?3.示例--向服务器发送请求注意,这只是一个声明,类似于java中声明一个服务. 但不调用的话,是不会绑定数据的
<fx:Declarations><s:HTTPService id="employeeService" url="http://adobetes.com/f4iaw100/remoteData/employees.xml"/></fx:Declarations>???一般情况下会在某个事件中调用这个服务示例中使用creationComplete调用,即当组件加载完成后,就现服务器发送请求
<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="employeeService.send()">??4.读取显示列表数据使用DropDownList 来读取数据,{}中间的就是读取数据的属性 testd.lastResult 就是读取的全部数据了,再按xml的节点,来一个一个的读取,这样可以读取list,这里要注意的是?dataProvider只到了对象,没有到对象后具体属性(展现在页面上的内容),这里使用了labelField,来表明具体要显示什么字段 ?而在phone这个textInput控件中,显示的则是选中的employee对象的phone属性.dropDownList为上面的id,selectedItem表明选中的对象,phone为具体的对象属性
<mx:Form x="87" y="73" width="290" height="98"><mx:FormItem label="test"><s:DropDownList id="dropDownList"labelField="lastName"dataProvider="{testd.lastResult.employees.employee}"/></mx:FormItem><mx:FormItem label="Office Phone:"><s:TextInput id="phone" text="{dropDownList.selectedItem.phone}"/></mx:FormItem></mx:Form> ???
效果如下
??
5.通过网络监视器来观察请求注意在flash builder4中,要先打开监控按钮,再点run. 才能监控到光打开监控,直接在浏览器中打开地址,貌似监控不到从这个面板可以看到请求及响应的详细信息?
???