Flex 處理服務(wù)器端傳來的數(shù)據(jù)第1/2頁
客戶端使用flex builder 3開發(fā),結(jié)構(gòu)就遵循flex builder 3標(biāo)準(zhǔn)
client.mxml為
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical">
<mx:RemoteObject destination="helloService"
id="test1">
<mx:method name="hello"
result="sayHelloResult(event)"/>
<mx:method name="world"
result="sayWorldResult(event)"/>
<mx:method name="getMap"
result="getMapResult(event)"/>
<mx:method name="getList"
result="getListResult(event)"/>
<mx:method name="getSet"
result="getSetResult(event)"/>
</mx:RemoteObject>
<mx:HBox>
<mx:Label text="輸入:"/>
<mx:TextInput id="inputStr"/>
<mx:Button label="say hello"
click="sayHello(event);"/>
<mx:Button label="say world"
click="sayWorld(event);"/>
<mx:Button label="get map"
click="test1.getMap()"/>
<mx:Button label="get list"
click="test1.getList()"/>
<mx:Button label="get set"
click="test1.getSet()"/>
</mx:HBox>
<mx:HBox>
<mx:Label text="結(jié)果:"/>
<mx:TextArea id="result"/>
</mx:HBox>
<mx:Script>
<!--[CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.FaultEvent;
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
import cn.Person;
[Bindable]
public var person:Person;
[Bindable]
public var map:ArrayCollection=null;
function sayHello(event:Event):void
{
var inputVar:String=inputStr.text;
test1.hello(inputVar);
}
function sayWorld(event:Event):void
{
var inputVar:String=inputStr.text;
test1.world(inputVar);
}
private function sayHelloResult(event:ResultEvent):void
{
result.text=event.result.toString();
Alert.show(event.result.toString(), "返回結(jié)果");
}
private function sayWorldResult(event:ResultEvent):void
{
result.text=event.result.toString();
Alert.show(event.result.toString(), "返回結(jié)果");
}
private function getMapResult(event:ResultEvent):void
{
for (var key:String in event.result)
{
var list:ArrayCollection=event.result[key] as ArrayCollection;
for (var key1:Object in list)
{
Alert.show("map item key is: " + key + " value is: " + key1);
}
}
}
private function getList():void
{
test1.getList();
}
private function getListResult(event:ResultEvent):void
{
var ac:ArrayCollection=event.result as ArrayCollection;
for (var i:int=0; i < ac.length; i++)
{
var p1:Person=ac.getItemAt(i) as Person;
Alert.show("list item name is: " + p1.name+" \n another usage : "+ac.getItemAt(i).name);
}
}
private function getSet():void
{
test1.getSet();
}
private function getSetResult(event:ResultEvent):void
{
var ac:ArrayCollection=event.result as ArrayCollection;
for (var i:int=0; i < ac.length; i++)
{
var p1:Person=ac.getItemAt(i) as Person;
Alert.show("set item name is: " + p1.name);
}
}
]]-->
</mx:Script>
</mx:Application>
相關(guān)文章
使用asx3m與xstream配合解決flex與java利用httpservice傳遞xml數(shù)據(jù)問題
過年期間抽空在弄flex前端對象與后端java對象利用httpservice交互的問題。比如前端需要user list數(shù)據(jù),構(gòu)造了flex user object類。2009-02-02flex SystemManger監(jiān)控用戶是否和程序打交道
flex中可以通過SystemManger監(jiān)控用戶是否和程序打交道2009-05-05在flex中執(zhí)行一個javascript方法的簡單方式
說明:這里巧妙的運用了JavaScript中的eval全局函數(shù),非常好,省的在嵌入flash的網(wǎng)頁文件中寫JavaScript函數(shù)。2009-05-05Flex 編程注意之Flex Complier參數(shù)
由于上一篇文章《Flex編程注意之Namespace的用法》引出了Flex編譯時自帶的兩個參數(shù):-namespace -include-namespace,正好想到可以寫一篇關(guān)于Flex Complier時的一些自定義參數(shù)。2009-07-07XML TO ArrayCollection 兩種實現(xiàn)方式
最近研究FLEX,在網(wǎng)上看過100遍同一篇文章,結(jié)果測試不通,不知道到底能不能跑通,最后翻資料自己試驗處理。2009-06-06Flex與.NET互操作(十二):FluorineFx.Net的及時通信應(yīng)用(Remote Shared Objects
遠程共享對象(Remote Shared Objects) 可以用來跟蹤、存儲、共享以及做多客戶端的數(shù)據(jù)同步操作。只要共享對象上的數(shù)據(jù)發(fā)生了改變,將會把最新數(shù)據(jù)同步到所有連接到該共享對象的應(yīng)用程序客戶端。2009-06-06