# \[Flash 8\]

**URL:** <https://forum.kirupa.com/t/flash-8/227073>\
**Category:** Uncategorized\
**Created:** [May 26, 2007, 6:04pm UTC](https://forum.kirupa.com/t/flash-8/227073 "2007-05-26T18:04:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pbear](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/pbear/32/3662_2.png) [@pbear](https://forum.kirupa.com/u/pbear)\
**Post date:** [May 26, 2007, 6:04pm UTC](https://forum.kirupa.com/t/flash-8/227073/1 "2007-05-26T18:04:48Z")

</div>

_Edit: Wasn’t sure what to call it and forgot the title! Fixed. 😊_

I’m working on an animation that switches “drawers” in and out of the stage. I’ve got the dynamic pathing mostly figured out (saves **lots** of redundant code), and solved a pesky “undefined” value error. But I’m stuck.

**The problem:** The last value of the loop is the only value passed to the onRelease function created in the loop. It identifies the last item in the (predefined) cabGen array (as shown below: “introduction”). I have changed the last item to test this and sure enough that is the variable assigned to every onRelease instance.

Sound familiar? 🙂 I know the solution is definitely [here, in the kirupa.com FAQ](http://www.kirupa.com/forum/showpost.php?p=1922781&postcount=7). But I’m hitting a wall in applying it. Maybe I’ve been staring too long at this code!

```auto
var cabGen:Array = ["navigation","artstores","specificcats","generalcats","bigmap","credits","introduction"];
// ...
var i:Number;
for (i = 0; i < cabGen.length; i++) {
    var cabGenFix:String = cabGen*; // because you can't call cabGen* in a loop that uses it
    cabGenFix.index = i;
    this["cb_navigation"]["sw_" + cabGen*].onRelease = function() {
        cabOld = cabCurrent;
        cabCurrent = cabGen[cabGenFix.index];
    }
}

```

(note: other variables cabOld/cabCurrent are properly initialized)

I’m deeply appreciative for any insight on this one.
