Controlling multiple external swfs from main timeline
ellenst Jun 26, 2011 7:16 PMHi, I've been trying to combine the features of two tutorials I found, one that deals with controlling external swf's from the main timeline and the other that explains how to load and unload multiple external swf's. I'd like to be able to load and unload multiple external swf's, and control these swf's buttons from the main timeline.
I asked this same question on the forum of the site where I found these tutorials, and receive only one reply saying that "it should'nt be hard to do." but they did not elaborate any further. This left me think that I was missing something very obvious and I've spent too much time now trying to work what it is now. I understand pretty much how both pieces of code work, but just can't work out how to combine them.
If someone could explain it to me, I'd much appreciate it.
Tutorial One code - controlling an external swf from the main timeline.
////////////////////////////////////////////////////
var ldr:Loader = new Loader();
var urlReq:URLRequest = new URLRequest("swfs/balls.swf");
ldr.load(urlReq);
function loadHandler (event:Event) {
var myClip:MovieClip = event.target.content;
addChild(myClip);
///////////////////////////////////////////////////////////////
function myClipOver(event:MouseEvent):void {
myClip.myBlueBalls.stop();
}
function myClipOut(event:MouseEvent):void {
myClip.myBlueBalls.play();
}
// set listeners
myClip.addEventListener(MouseEvent.ROLL_OVER, myClipOver);
myClip.addEventListener(MouseEvent.ROLL_OUT, myClipOut);
///////////////////////////////////////////////////////////////
}
// listener
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, loadHandler);
Tutorial Two code - loading and unloading multiple external swfs.
////////////////////////////////////////////////////
var Xpos:Number = 110;
var Ypos:Number = 180;
var swf:MovieClip;
var loader:Loader = new Loader();
var defaultSWF:URLRequest = new URLRequest("swfs/eyesClosed.swf");
loader.load(defaultSWF);
loader.x = Xpos;
loader.y = Ypos;
addChild(loader);
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////
// Btns Universal function
function btnClick(event:MouseEvent):void {
removeChild(loader);
var newSWFRequest:URLRequest = new URLRequest("swfs/" + event.target.name + ".swf");
loader.load(newSWFRequest);
loader.x = Xpos;
loader.y = Ypos;
addChild(loader);
}
// Btn listeners
eyesClosed.addEventListener(MouseEvent.CLICK, btnClick);
stingray.addEventListener(MouseEvent.CLICK, btnClick);
demon.addEventListener(MouseEvent.CLICK, btnClick);
strongman.addEventListener(MouseEvent.CLICK, btnClick);



