2007年11月6日 星期二

好消息!!PHPRPC for AS3.0 正式支援RIA啦(Flex完美運行)

PHPRPC出新支援的語言啦…100%支援ActionScript 3.0

經過我測試結果,PHPRPC for Flash和PHPRPC for Flex皆可完美運行。

現在就先貼上PHPRPC在flex的運行範例和原始碼:

PHPRPC for Flex (Hi Flex)

http://bawbaw.deep.tw/test_flex/phprpc.html

Flex原碼

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
width="806" height="200"
horizontalAlign="center" verticalAlign="middle"
>
<mx:Script>
<![CDATA[
import flash.events.MouseEvent;
import org.phprpc.PHPRPC_Error;
import org.phprpc.PHPRPC_Client;//import PHPRPC_Client
private function clickHandler ( event:MouseEvent ):void
{
// myLabel.text = "Hello, World!";
var rpc:PHPRPC_Client = new PHPRPC_Client('http://bawbaw.deep.tw/rpc_server.php', ['hi']);
//rpc.setEncryptMode(2);
rpc.hi('test','en', function (result:*, args:Array, output:String, warning:PHPRPC_Error):void {
myLabel.text = result;
});
}
]]>
</mx:Script>


<mx:Panel
title="PHPRPC for Flex" horizontalAlign="center"
paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10"
width="744" height="123">

<mx:Label id="myLabel" width="640" fontWeight="bold" fontSize="24"/>
<mx:Button id="myButton" label="Click Me!" click="clickHandler(event);" />

</mx:Panel>
</mx:Application>



PHPRPC for Flex (雅虎字典)
http://bawbaw.deep.tw/test_flex/yahoo_dict.html

Flex原碼:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
width="604" height="498"
horizontalAlign="center" verticalAlign="middle"
>
<mx:Script>
<![CDATA[
import flash.events.MouseEvent;
import org.phprpc.PHPRPC_Error;
import org.phprpc.PHPRPC_Client;//import PHPRPC_Client
private function clickHandler ( event:MouseEvent ):void
{
var rpc:PHPRPC_Client = new PHPRPC_Client('http://bawbaw.deep.tw/rpc_server.php', ['yahoo_dict']);
//rpc.setEncryptMode(2);
rpc.yahoo_dict(q.text,true, function (result:*, args:Array, output:String, warning:PHPRPC_Error):void {
rs_str.text=result;
});
}
]]>
</mx:Script>


<mx:Panel
title="PHPRPC for Flex" horizontalAlign="center"
paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10"
width="528" height="435">
<mx:TextInput id="q"/>
<mx:Button id="myButton" label="查字典!" click="clickHandler(event);" />
<mx:Text width="413" height="293" id="rs_str" fontSize="15"/>

</mx:Panel>
</mx:Application>