Placing Array Values into Variables to Control Instances

Hi there, I am having some troubles with pulling some values out of an array into a variable and then using that variable to control an Instance value assigned to a set of buttons.

Frame 1 (scene 1) Actionscript


gMarray=new Array();
gMarray[0] = 4; 
gMarray[1] = 1; 
gMarray[2] = 1; 
gMarray[3] = 1; 
gMenuListarray=new Array();
gMenuListarray[0] = "gbLaw";
gMenuListarray[1] = "gbPrev";
gMenuListarray[2] = "gbPower";
gMenuListarray[3] = "gbHandle";

Frame 1 (scene 2) Actionscript


for(i=0; i<=3; i++){ //if i is 3 or less do...
	var gTemp1=gMarray*;
	trace(gTemp1);  // display the value held
	for(j=1; j<=4; j++){ //if j is 4 or less do...
		var gTemp2=(gMenuListarray*+j);
		trace(gTemp2);
		if(gTemp1 == j){ //check and see if the variable in a gM# is equal to j
			gTemp2._visible=1;
		}else{
			gTemp2._visible=0;
		}
	}
}

gMarray is being used to hold a value (for tracking).
gMenuListarray is being used to hold the names of the button instances.

As the script goes through the for loops it adds j to the value of whatever is in gMenuListarray item i (ie. gbLaw1, gbLaw2, etc.) then it checks if the value of gMarray is equal to j, if it is equal it makes the instance name that equals the combined value of gMenuListarray (array item plus j appended to it) visible or invisible on the stage. The problem is that Flash MX 2004 seems to be incapable of reading using this combined value to find and modify the instance, it goes into the loop, compares and then exits out without doing anything. I have check my logic using a trace command to tell me “true” or “false” and that works correctly and I have double checked to ensure that the combined value of gMenuListarray+j equals an Instance name asigned to a button on my stage.

Thoughts? Comments? Suggestions? A hammer to beat this software into submission?