Greetings, heres the mockup for what i am trying to do.
i have an array with buttons, and “the to be loaded swf” files.
how can i pass on the variables for which swf to load? i searched my books but i have issues.
i can trace out btn.swftoload
but if i want to store btn.swftoload in a variable i get errors, i tried string, object & movieclip.
my intention is to store it as “currentMovie”, so i can reuse the code for later on.
Can anyone help me out?
Thanks in advance.
var buttons:Array = new Array ("button1", "button2", "button3", "button4", "button5", "button6");
var swf_array:Array = new Array ("swf1.swf","swf2.swf","swf3.swf","swf4.swf","swf5.swf","swf6.swf");
function loadMe (currentMovie):void
{
var ldr:Loader = new Loader();
ldr.load (new URLRequest(currentMovie));
ldr.contentLoaderInfo.addEventListener (Event.COMPLETE, loaded);
}
function loaded (evt:Event):void
{
loaderclip.addChild (evt.target.content);
}
function loadMe ():void
{
var ldr:Loader = new Loader();
ldr.load (new URLRequest(btn.swftoload));
ldr.contentLoaderInfo.addEventListener (Event.COMPLETE, loaded);
}
function loaded (evt:Event):void
{
loaderclip.addChild (evt.target.content);
}
function clickedbutton (btn:Object):void
{
trace ("swf = " + btn.swftoload);
//traces out correctly, but not when i store it in a variable.
if (btn.swftoload == undefined)
{
currentMovie = btn.swftoload
loadMe (currentMovie);
} else if (loaderclip.currentFrame >= loaderclip.contentframe)
{
currentMovie = btn.swftoload;
}
disabledBtn = btn;
}
function onCLICK (event:MouseEvent):void
{
btn = event.currentTarget;
clickedbutton (btn);
}
for (var i:String in buttons)
{
buttons*.swftoload = swf_array*;
buttons*.buttonMode = true;
buttons*.button_txt.mouseChildren = false;
buttons*.addEventListener (MouseEvent.CLICK,onCLICK);
}