- 範例雖是Flex撰寫,但由於使用NetConnection來做Remote連線,所以Flash也適用。
example:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application applicationComplete="init();" xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
private var _btnEnable:Boolean;
private function init():void
{
_btnEnable = true;
initNetConnection();
}
private var _nc:NetConnection;
private function initNetConnection():void
{
_nc = new NetConnection();
//回呼處理物件
_nc.client = this;
//序列化格式指定
_nc.objectEncoding = ObjectEncoding.AMF3;
//指定AMFServer服務位置
_nc.connect(amfServerUri);
_nc.addEventListener(NetStatusEvent.NET_STATUS , onStatus);
}
private var amfServerUri:String="http://127.0.0.1/flashservices/gateway.php";
private var _source:String = "tw.remote.test.Hello.sayHello";