Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi all, I have a solution but I would like to hear some comments about it:
I have a flash player 8 swf movie (as2) that needs to be loaded controlled and communicated by a flash player 9-10 (as3).
This was a nightmare for me until I solved it out with local connection. (AVM1 to AVM2 connection and viceversa).
Now local connection had to be established both on the AS2 and the AS3 movies.
I ran into the same problems everyone here are describing :
Error #2082: Connect failed because the object is already connected
Usually because several browsers were open the same time, and even several tabs in the same browsers.
What I did is as follows:
first an outline of the process:
1. load external movie with a query cache killer string :myMovie.swf?ck=1894677
2. on the loaded external movie get the querystring.
3. open local connection key in both movies - that has the key name of the querystring.
4. I had to create 2 connections (viceversa) so I made one key = querystring , the other = querystring+"_out"
5. BOOOM IT WORKS!!! - since each browser page has a different local connection key - there are no conflicts.
6. Tested with Firefox 3.5 at 2 tabs opened with the same site, two tabs of IE7, one chrome, one opera - all open at the same time!!!!!!
--------------------
for the long explanation (this is not the entire code - just snippets .. so use this wisely)
I usually add a cache killer to my external loaded movies ( a string that changes the name of the downloaded swf file so it will not be cached by the
browser - and by that I am getting a fresh copy of the file , every time).
So instead of loading: myMovie.swf , I load myMovie.swf?ck=1894677 for example.
this can be done like this:
in the main as3 movie:
var AVM_lc:LocalConnection = new LocalConnection();
var AVM_listener:LocalConnection ;
var myClient:Object;
var randomLCname:String;
var randomLCnameOutgoing:String;
randomLCname = String(getTimer()) + String(Math.round(Math.random() * 10000));
randomLCnameOutgoing = randomLCname + "_out";
theMoviePath = "externalAs2movie.swf?ck="+randomLCname;
var movRequest:URLRequest = new URLRequest(theMoviePath)
movLoader.load(movRequest);
after the movie is loaded I create two local connections to the as2 movie:
//incoming
AVM_listener = new LocalConnection();
myClient = new Object();
AVM_listener.client = myClient;
myClient.gotoProjects = function () {
// a function to execute once I get a note from the as2 external loaded movie
};
try {
AVM_listener.connect(randomLCname);
} catch (error:ArgumentError) {
w(error.toString())
}
// outgoing whenever I want I do:
AVM_lc.send(randomLCnameOutgoing, "playAnime");
//or
AVM_lc.send(randomLCnameOutgoing, "resetAnime");
now in the loaded movie (for this example it is an as2 movie - but can be done on an AS3 movie as well, at least I think so...)
I am reading the querystring (it is different in as3.....):
in the external as2 that is loaded into the as3:
var avm1toavm2:String = _root.ck; // do not forget the _root in as2
var avm2toavm1:String = avm1toavm2+"_out";
// local connection instance to receive events
var AVM_lc:LocalConnection = new LocalConnection();
// stopAnimation event handler - a command to stop the animation - inside the as2 external movie
AVM_lc.stopAnimation = function(){
stop();
}
//etc.
AVM_lc.resetAnime = function(){
gotoAndStop(1);
}
AVM_lc.playAnime = function(){
gotoAndPlay(1);
}
// listen for events for "AVM2toAVM1" - it means from the as3 file to this as2 file
AVM_lc.connect(avm2toavm1); // avm2toavm1 this parameter was defined earlier in this code
//--------------- create a connection to comunicate with the as3 movie
var sendToAs3:LocalConnection = new LocalConnection();
function movieIsOver(){ // this is a function that will be executed when the as2 movie is over
sendToAs3.send(avm1toavm2, "gotoProjects");
}
stop();
-------------------------- complicated but works!!!!!
Can anyone comment?
Can I have hundreds of localConnections the same time (assuming I did not close the others, while shuting the browser?????)
Gidon
Koomkoom Multimedia
info@koomkoom.com
site:
www.koomkoom.com
Copy link to clipboard
Copied
I have the same problem with Windows AIR application. Also this issue appears after system awake from hibernation.
Steps to reproduce:
1) Connect to a LocalConnection.
2) Hibernate your Windows device and then wake it.
Result: LocalConnection works no more. You need to reboot device.
Adobe, please fix this issue.
Copy link to clipboard
Copied
OMG, can't even believe I wrote my comment 8 years ago.
FLASH IS DEAD.
I've moved on...
Gidon