[問題] AS3 <-> AS2 的 localconnection

看板Flash作者時間17年前 (2009/04/21 17:53), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
我正在寫一個用 localconnection 使 AS3 和 AS2 的SWF 互相通訊的code 但連線的部份有點怪怪的,可以確定接收端有 run我指定的function,但不曉得為什麼 StatusEvent裡的 level 一直是 error AS3(傳送端): var envoy:LocalConnection = new LocalConnection(); envoy.connect("avm2"); envoy.client = this; //檢查localconnection是否抓得到另一端 envoy.addEventListener(StatusEvent.STATUS,statusHandler); function statusHandler(e:StatusEvent){ if(e.level == "status"){ trace("connection successed"); } else if(e.level == "error"){ trace("failed"); } } var loader:Loader = new Loader(); loader.load(new URLRequest("1.swf")); loader.contentLoaderInfo.addEventListener(Event.INIT,loaderInit,false,0,true); function loaderInit(e:Event){ addChild(loader); envoy.send("avm1","Res"); envoy.send("avm1","sStop"); } ========================下面開始是 AS2 (接收端)======================== var envoy:LocalConnection = new LocalConnection(); envoy.connect("avm1"); envoy.Res = function():Void { trace("this is Res"); } ======================================================================== run的結果, 會成功跑進 接收端的 envoy.Res function 也有 trace出"this is Res" 可是在 傳送端的 StatusEvent 中的 level一直是 error 請問一下我哪邊寫錯了嗎? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.120.37.117
文章代碼(AID): #19xPUfzm (Flash)
文章代碼(AID): #19xPUfzm (Flash)