# For loop with multiple arrays and loader

**URL:** <https://forum.kirupa.com/t/for-loop-with-multiple-arrays-and-loader/272799>\
**Category:** Uncategorized\
**Created:** [October 8, 2008, 4:09pm UTC](https://forum.kirupa.com/t/for-loop-with-multiple-arrays-and-loader/272799 "2008-10-08T16:09:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![muflyn](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@muflyn](https://forum.kirupa.com/u/muflyn)\
**Post date:** [October 8, 2008, 4:09pm UTC](https://forum.kirupa.com/t/for-loop-with-multiple-arrays-and-loader/272799/1 "2008-10-08T16:09:44Z")

</div>

Hi everyone,

I’m creating a full flash site using multiple swfs that open inside a main swf. The main swf is a menu with 6 mc buttons, each one has to open a specific swf into a loader and stay in the “down” state. I’ve done all this in separated files and succeded, but I can’t make them work all together… At the moment I have two arrays, one for the buttons e other for the swf, and I have the loader created. I also have a function with a for loop that controls the “down” state of the buttons. What I’m missing is for the loop for my other array (can be in the same function I guess) and make the swf’s to open inside the loader.  
I feel like an unsuccessful Victor Frankenstein… does anyone has some enlightenment? please help making my script live! :frankenstein:

Here’s it is:

var buttonsArray : Array = [mc\_01, mc\_02, mc\_03, mc\_04, mc\_05, mc\_06];  
var swfArray : Array = [“01.swf”, “02.swf”, “03.swf”, “04.swf”, “05.swf”, “06.swf”];  
var container:Loader = new Loader();  
addChild(container);  
//  
function setButtons():void {  
for (var i:int=0; i\<buttonsArray.length; i++) {  
buttonsArray\*.id = i;  
buttonsArray\*.buttonMode = true;  
buttonsArray\*.mouseChildren = false;  
buttonsArray\*.mouseEnabled = true;  
buttonsArray\*.addEventListener(MouseEvent.ROLL\_OVER,playOver);  
buttonsArray\*.addEventListener(MouseEvent.ROLL\_OUT,playOut);  
buttonsArray\*.addEventListener(MouseEvent.CLICK,doClick);  
}  
}  
//  
function playOver(event:MouseEvent):void {  
event.currentTarget.gotoAndStop(“over”);  
}  
function playOut(event:MouseEvent):void {  
event.currentTarget.gotoAndStop(“out”);  
}  
function doClick(event:MouseEvent):void {  
var currentBtn:int = event.currentTarget.id;  
setSelectedBtn(currentBtn);  
}  
function setSelectedBtn(id:int):void {  
for (var i:int=0; i\< buttonsArray.length; i++) {  
if (id == i) {  
buttonsArray\*.gotoAndStop(“down”);  
buttonsArray\*.buttonMode = false;  
buttonsArray\*.mouseEnabled = false;  
buttonsArray\*.removeEventListener(MouseEvent.ROLL\_OVER,playOver);  
buttonsArray\*.removeEventListener(MouseEvent.ROLL\_OUT,playOut);  
buttonsArray\*.removeEventListener(MouseEvent.CLICK,doClick);  
} else {  
if (buttonsArray\*.currentLabel ==“down”) {  
buttonsArray\*.gotoAndStop(“out”);  
}  
buttonsArray\*.buttonMode = true;  
buttonsArray\*.mouseEnabled = true;  
buttonsArray\*.addEventListener(MouseEvent.ROLL\_OVER,playOver);  
buttonsArray\*.addEventListener(MouseEvent.ROLL\_OUT,playOut);  
buttonsArray\*.addEventListener(MouseEvent.CLICK,doClick);  
}  
}  
}  
setButtons();

Tks
