facebook twitter hatena line email

Flash/as3/LocalConnection

提供: 初心者エンジニアの簡易メモ
移動: 案内検索

localconnection

*送信
import flash.net.LocalConnection;
import flash.events.StatusEvent;
connect:LocalConnection = new LocalConnection();
connect.send("myConnect", "method1", "str1");
connect.addEventListener(StatusEvent.STATUS, onStatus);
private function onStatus(event:StatusEvent):void {
  switch (event.level) {
   case "status":
       trace("LocalConnection.send() succeeded");
       break;
   case "error":
       trace("LocalConnection.send() failed");
       break;
  }
}
*受信
import flash.net.LocalConnection;
import flash.text.TextField;
connect:LocalConnection = new LocalConnection();
connect.client = this;
connect.connect("myConnect");
public function method1(str:String):void{
  var txt:TextField = new TextField();
  txt.text = str;
  addChild(txt);
}