Difference between revisions of "LocalConnection"
From Wikicliki
| Line 1: | Line 1: | ||
| + | LocalConnection is a way to send messages between different flash files embedded in the same html page. | ||
| + | |||
== AS2 Local Connection == | == AS2 Local Connection == | ||
| Line 7: | Line 9: | ||
b01_1.onRelease = function() { | b01_1.onRelease = function() { | ||
| − | sending_lc.send(" | + | sending_lc.send("locallyConnecting", "execute_this", "b01_1"); |
} | } | ||
b01_2.onRelease = function() { | b01_2.onRelease = function() { | ||
| − | sending_lc.send(" | + | sending_lc.send("locallyConnecting", "execute_this", "b01_2"); |
} | } | ||
b01_3.onRelease = function() { | b01_3.onRelease = function() { | ||
| − | sending_lc.send(" | + | sending_lc.send("locallyConnecting", "execute_this", "b01_3"); |
} | } | ||
b02_1.onRelease = function() { | b02_1.onRelease = function() { | ||
| − | sending_lc.send(" | + | sending_lc.send("locallyConnecting", "execute_this", "b02_1"); |
} | } | ||
b02_2.onRelease = function() { | b02_2.onRelease = function() { | ||
| − | sending_lc.send(" | + | sending_lc.send("locallyConnecting", "execute_this", "b02_2"); |
}</pre> | }</pre> | ||
| Line 31: | Line 33: | ||
gotoAndPlay(new_text); | gotoAndPlay(new_text); | ||
} | } | ||
| − | receiving_lc.connect(" | + | receiving_lc.connect("locallyConnecting"); |
</pre> | </pre> | ||
| Line 46: | Line 48: | ||
function b01_1_send(evt:MouseEvent):void { | function b01_1_send(evt:MouseEvent):void { | ||
| − | sending_lc.send(" | + | sending_lc.send("locallyConnecting", "execute_this", "b01_1"); |
} | } | ||
function b01_2_send(evt:MouseEvent):void { | function b01_2_send(evt:MouseEvent):void { | ||
| − | sending_lc.send(" | + | sending_lc.send("locallyConnecting", "execute_this", "b01_2"); |
} | } | ||
function b01_3_send(evt:MouseEvent):void { | function b01_3_send(evt:MouseEvent):void { | ||
| − | sending_lc.send(" | + | sending_lc.send("locallyConnecting", "execute_this", "b01_3"); |
} | } | ||
function b02_1_send(evt:MouseEvent):void { | function b02_1_send(evt:MouseEvent):void { | ||
| − | sending_lc.send(" | + | sending_lc.send("locallyConnecting", "execute_this", "b02_1"); |
} | } | ||
function b02_2_send(evt:MouseEvent):void { | function b02_2_send(evt:MouseEvent):void { | ||
| − | sending_lc.send(" | + | sending_lc.send("locallyConnecting", "execute_this", "b02_2"); |
} | } | ||
| Line 76: | Line 78: | ||
var receiving_lc:LocalConnection; | var receiving_lc:LocalConnection; | ||
receiving_lc = new LocalConnection(); | receiving_lc = new LocalConnection(); | ||
| − | receiving_lc.connect(" | + | receiving_lc.connect("locallyConnecting"); |
receiving_lc.client = this; | receiving_lc.client = this; | ||
function execute_this(new_text:String):void { | function execute_this(new_text:String):void { | ||
Latest revision as of 10:36, 15 September 2011
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);
}