Groups | Blog | Home
all groups > flash actionscript > august 2004 >

flash actionscript : Mutidimensional Array and FOR Loop problem


dutchoh1
8/19/2004 8:43:56 PM
I am STUMPED....

A quick background on what I am doing...

I have multiple instances of a movie clip symbol on a stage. Naming
convention of r1, r2, r3, r4, ....r16.

in each movie clip I have frame labels of - label0, label1, label2, and label3.

Ultimately I am trying to make it so that when I press a button it will set 16
numbers withing a multidimensional array. in this instance pickClip
[[1,3,5,7], [2,4,6,8], [9,11,13,15], [10,12,14,16]];

I then call a function which is supposed to loop through two FOR Loops ( one
is nested) and tell the individual instances what frame label to gotoAndPlay
when the button is pressed.

Basically depending on which button is pressed I want to give the function
different array values which will make the multiple instances start playing
at frame label the function tells them too. If that makes any sense.

any help would be greatly appreciated...I have been banging my head on the
desk for two days and the swelling wont go down....

Thanks Brian P

Attached is the file for a better understanding...

This is what I have, not sure where I went wrong if I am even close. Looked
good on paper...

var pickClip:Array = new Array ();

function findFrame () {
for(i=0; i<4; ++i) {
for(j=0; j<4; ++j){
var numberClip:Number = _root.pickClip[j];
var mcLabel:String = "r" + numberClip;
_root[mcLabel].gotoAndPlay("label" + i);
};
};
}


button_mc.onRelease = function(){
_root.pickClip[0][0]= 1;
pickClip[0][1]=3;
pickClip[0][2]=5;
pickClip[0][3]=7;
pickClip[1][0]=2;
pickClip[1][1]=4;
pickClip[1][2]=6;
pickClip[1][3]=8;
pickClip[2][0]=9;
pickClip[2][1]=11;
pickClip[2][2]=13;
pickClip[2][3]=15;
pickClip[3][0]=10;
pickClip[3][1]=12;
pickClip[3][2]=14;
pickClip[3][3]=16;
trace("Why wont this work?");

findFrame();

}




Jack.
8/19/2004 9:16:05 PM
declare your array dimensions with -
var pickClip:Array = [[],[],[],[]];

dutchoh1
8/20/2004 1:13:46 PM
Awesome!

I figured it was something simple. I am just learning on my own for the most part.

Thank you very much!

Brian P
AddThis Social Bookmark Button