不知道我哪裏錯了,現在只是在本地嘗試。謝謝。AS3本地連接錯誤
sendingLC.swf不返回,調用LocalConnection.send()成功
這是我從Flash得到了錯誤。 錯誤#2044:未處理的AsyncErrorEvent :. text =錯誤#2095:flash.net.LocalConnection無法調用回調myMethod。錯誤= ReferenceError:錯誤#1069:在flash.net.LocalConnection上找不到屬性myMethod,並且沒有默認值。
代碼sendingLC.swf:
import flash.net.LocalConnection
var sendingLC:LocalConnection;
sendingLC = new LocalConnection();
sendingLC.allowDomain('*');
Security.allowDomain("*");
sendBtn.addEventListener(MouseEvent.CLICK, sendIt);
function sendIt(eventObj:MouseEvent):void {
sendingLC.send('myConnection', 'myMethod');
}
sendingLC.addEventListener(StatusEvent.STATUS, statusHandler);
function statusHandler (event:StatusEvent):void
{
switch (event.level)
{
case "status" :
textArea.text = ("LocalConnection.send() succeeded");
break;
case "error" :
textArea.text = ("LocalConnection.send() failed");
break;
}
}
代碼receivingLC.swf:
import flash.net.LocalConnection
var receivingLC:LocalConnection;
receivingLC = new LocalConnection();
receivingLC.allowDomain('*');
Security.allowDomain("*");
receivingLC.connect('myConnection');
function myMethod():void {trace('Hello World')}
你在什麼時候調用sendIt函數?這兩個swf的加載? –
我打開這兩個瑞士法郎,然後點擊sendBtn,它調用sendIt – Chuck
他們是否在瀏覽器中打開? –