<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http:
layout="absolute"
creationComplete="initConn()"
backgroundAlpha="0" backgroundColor="#FFFFFF">
<mx:Script>
<![CDATA[
import flash.net.LocalConnection;
private var conn:LocalConnection;
private function initConn():void{
btnSend.addEventListener(MouseEvent.CLICK, sendMessage);
conn = new LocalConnection();
conn.addEventListener(StatusEvent.STATUS, onStatus);
}
private function sendMessage(event:MouseEvent):void {
conn.send("taskConnection", "localconnectionHandler", inputTask.text);
}
private function onStatus(event:StatusEvent):void {
switch (event.level) {
case "status":
labelStatus.text = "LocalConnection.send() succeeded";
break;
case "error":
labelStatus.text = "LocalConnection.send() failed";
break;
}
}
]]>
</mx:Script>
<mx:Panel horizontalCenter="0" verticalCenter="0">
<mx:Form width="100%" height="100%" horizontalCenter="0" verticalCenter="0">
<mx:FormItem label="Enter Task">
<mx:TextInput id="inputTask"/>
</mx:FormItem>
<mx:FormItem label="Send Task ">
<mx:Button id="btnSend" label="Send"/>
</mx:FormItem>
<mx:ControlBar>
<mx:Label id="labelStatus" text=""/>
</mx:ControlBar>
</mx:Form>
</mx:Panel>
</mx:Application>
What if I have two SWF's where one is loaded into the other via SWFLoader? Should I still use LocalConnection in that case, or there another better way to communicate between the two?
In this particular case, they both run in the system domain so that they don't try to use each other's imported WSDL reference and CSS.