# Pass var from Array into JS Function

**URL:** <https://forum.kirupa.com/t/pass-var-from-array-into-js-function/243387>\
**Category:** flash\
**Created:** [November 6, 2007, 3:47pm UTC](https://forum.kirupa.com/t/pass-var-from-array-into-js-function/243387 "2007-11-06T15:47:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jrutter](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/jrutter/32/2004_2.png) [@jrutter](https://forum.kirupa.com/u/jrutter)\
**Post date:** [November 6, 2007, 3:47pm UTC](https://forum.kirupa.com/t/pass-var-from-array-into-js-function/243387/1 "2007-11-06T15:47:29Z")

</div>

I am so close to getting this working, I have created an array and Im trying to extract a value from the array and pass it into my javascript function - which passes it to my javascript function in my HTML page. Im so close, when I click a button - it passes the var stateName, but its not pulling the state into that from the array. Can someone look at my code and help me out with this?

```auto
var buttonList:Array = [washington, oregon];
for (var i:Number = 0; i < buttonList.length; i++) {
  var mcBtn:MovieClip = buttonList*;
  mcBtn.stop();
  mcBtn.onRollOver = function():Void {
    this.gotoAndStop("onRollover");
    new Tween(this, "_xscale", Regular.easeOut, this._xscale, 150, 0.3, true);
    new Tween(this, "_yscale", Regular.easeOut, this._yscale, 150, 0.3, true);
    this.swapDepths(500);

};
    mcBtn.onRollOut = function():Void {
    this.gotoAndStop("onRollout");
    new Tween(this, "_xscale", Regular.easeOut, this._xscale, 100, 0.3, true);
    new Tween(this, "_yscale", Regular.easeOut, this._yscale, 100, 0.3, true);
    };

    for (var m:Number = 0; m < buttonList.length; m++) {
             var stateName:String = buttonList[m];
            mcBtn.onRelease = function():Void {
                ExternalInterface.call("selectState('stateName')");

            }
            trace(stateName);
    }
}

```

Thanks in advance!
