# Passing on variables

**URL:** https://forum.kirupa.com/t/passing-on-variables/285887
**Category:** Uncategorized
**Created:** [April 7, 2009, 4:07pm UTC](https://forum.kirupa.com/t/passing-on-variables/285887 "2009-04-07T16:07:59Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![nitras](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/nitras/32/1475_2.png) [@nitras](https://forum.kirupa.com/u/nitras)
#### Post date: [April 7, 2009, 4:07pm UTC](https://forum.kirupa.com/t/passing-on-variables/285887/1 "2009-04-07T16:07:59Z")

</div>

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.

```auto

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);
}

```
