I am trying to load a different swf movie into my many swf movies on a single html page.
I have a controller swf … which has an array of paths for these movies which are jumbled up upon the load of the html page.
I have (say 6) other swfs (reciever.swf) loading into the page, which all have a unique ID through as flashVar, denoting them as 0, 1, 2 etc…
Simply enough each reciever looks at the controller’s array, and inputs its ID to get its path to load a random, yet unique SWF.
I am having problems with getting this to work with local connection though …
Here is my code for the controller and the reciever … Can anyone help out why it’s not working past the first reciever…
controller.swf
var ranAry:Array = new Array("zero","one","two","three","four");
function randomise()
{
r = function()
{
return random(2)*2-1;
};
ranAry.sort(r);
}
randomise();
var to:String;
var from:String;
var num:Number = 0;
var IN:LocalConnection = new LocalConnection();
var OUT:LocalConnection = new LocalConnection();
to = "movie"+num;
from = "from"+num;
OUT.send(to, "recieve_ary", ranAry);
IN.LoadNext = function(textRecieved:String)
{
error_txt.text = num;
num++;
from = "from"+num;
to = "movie"+num;
OUT.send(to, "recieve_ary", ranAry);
IN.connect(from);
}
IN.connect(from);
And here’s the code for the reciever.swf::
var IN:LocalConnection = new LocalConnection();
var OUT:LocalConnection = new LocalConnection();
var flashVars:Number = ID;
var from:String = "from"+ID;
var to:String = "movie"+ID
IN.recieve_ary = function(ranAry:Array)
{
varTxt.text = ranAry[ID];
OUT.send(from, "LoadNext", "OK");
};
IN.connect(to);
That SHOULD work right!!!? I just cant get it to
I have had to implement a setInterval to get it working properly (the dirty way) …