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

flash actionscript : Problem using an array of MCs for a menu


jkettler
8/4/2006 7:07:28 PM
I'm creating an animated menu using a series of MCs and wrote a function to
reset them back to frame 1 whenever you choose a new menu item. I couldn't get
it to work so I did a trace to see if I could even get the value of the current
MC's frame & I get "undefined". I only have 2 MCs in the array right now to
keep things simple. Any idea of what I'm doing wrong?



function resetMenu() {
var clipArray:Array = new Array("td_mc", "team_mc");
var x=0;
var cntr=clipArray.length;
do {
if (clipArray[x]._currentframe != 1){
clipArray[x].gotoAndStop(1);
trace(clipArray[x]._currentframe);
}
x++;
}
while(x < cntr);
}
chrism59
8/5/2006 1:25:00 AM
I'm not sure if theis will help but if you are moving all the movies to the
first frame this code will work

for (x=0,x<clipArray.length;++x){
eval(clipArray[x]).gotoAndStop(1)
}

I believe that the issue is that you are you need to covert a string value
stored in the array to a movieClip object. the eval(StringVariable) will make
AS convert the string object to a MovieClip object.
butcho
8/5/2006 2:08:14 AM
Hi,

there is a simple way to achieve that.. Put all your buttons in one mc and
call that mc buttonsMc.

With a for in loop you will be able to do what you want. Ill post a version
that will escape the movieclip button that is pressed; mainly because usually
you want to reset all the other buttons but not the one pressed .. do here is
the code:



function resetMc(_mc:MovieClip){
for(var each in buttonsMc){
if(buttonsMc[each] != _mc){
buttonsMc[each].gotoAndStop(1);
}
}
}
jkettler
8/7/2006 12:00:00 AM
Thanks to both of you for all your help.

AddThis Social Bookmark Button