LocalConnection
From Wikicliki
LocalConnection is a way to send messages between different flash files embedded in the same html page.
Contents
AS2 Local Connection
Sender
sending_lc = new LocalConnection(); b01_1.onRelease = function() { sending_lc.send("locallyConnecting", "execute_this", "b01_1"); } b01_2.onRelease = function() { sending_lc.send("locallyConnecting", "execute_this", "b01_2"); } b01_3.onRelease = function() { sending_lc.send("locallyConnecting", "execute_this", "b01_3"); } b02_1.onRelease = function() { sending_lc.send("locallyConnecting", "execute_this", "b02_1"); } b02_2.onRelease = function() { sending_lc.send("locallyConnecting", "execute_this", "b02_2"); }
Receiver
stop(); receiving_lc = new LocalConnection(); receiving_lc.execute_this = function(new_text) { tracetext.text = "tracing LC var: "+new_text; gotoAndPlay(new_text); } receiving_lc.connect("locallyConnecting");
AS3 LocalConnection
Sender
stop(); var sending_lc:LocalConnection; sending_lc = new LocalConnection(); function b01_1_send(evt:MouseEvent):void { sending_lc.send("locallyConnecting", "execute_this", "b01_1"); } function b01_2_send(evt:MouseEvent):void { sending_lc.send("locallyConnecting", "execute_this", "b01_2"); } function b01_3_send(evt:MouseEvent):void { sending_lc.send("locallyConnecting", "execute_this", "b01_3"); } function b02_1_send(evt:MouseEvent):void { sending_lc.send("locallyConnecting", "execute_this", "b02_1"); } function b02_2_send(evt:MouseEvent):void { sending_lc.send("locallyConnecting", "execute_this", "b02_2"); } b01_1.addEventListener(MouseEvent.MOUSE_UP, b01_1_send); b01_2.addEventListener(MouseEvent.MOUSE_UP, b01_2_send); b01_3.addEventListener(MouseEvent.MOUSE_UP, b01_3_send); b02_1.addEventListener(MouseEvent.MOUSE_UP, b02_1_send); b02_2.addEventListener(MouseEvent.MOUSE_UP, b02_2_send);
Receiver
stop(); var receiving_lc:LocalConnection; receiving_lc = new LocalConnection(); receiving_lc.connect("locallyConnecting"); receiving_lc.client = this; function execute_this(new_text:String):void { tracetext.text = "tracing LC var: "+new_text; gotoAndPlay(new_text); }