PDA

View Full Version : undefined array


owl527
06-07-2003, 11:32 PM
Hi,
I am trying to use an array to store some values. I defined the array button_array = new Array(); in the first frame of main scene. In that scene I have a menu which contains a lot of button, everytime when a button is hit, the value of the button will be added to the button_array. This is my code for each button:
onClipEvent(load){
gotoAndPlay(1);
state="off";
}
on(Press){
if (state=="on"){
state="off";
i--;
button_array.pop();
trace (i);
trace(button_array);
gotoAndStop(1);

}
else if (state=="off"){
state="on";
i++;
button_array.push("1");
trace (i);
trace (button_array);
gotoAndStop(10);

}
_root.click._visible = 0;

}

on(rollOver) {
if (state=="off"){
this.gotoAndPlay(5);
}
else if (state=="on"){
this.gotoAndStop(10);
}
}
on (rollOut) {
if (state=="off"){
this.gotoAndStop(1);
}
else if (state=="on"){
this.gotoAndStop(10);
}
}


I am not too sure why I keep getting "undefined" when I try to trace my button_array.
Hope someone can help me. Thank you so much for your time.

owl527
06-07-2003, 11:37 PM
forgot to attach my file....this is what I have....

CyanBlue
06-08-2003, 12:00 AM
Howdy and Welcome... ;)

I am not sure what you are trying to do there, but there is a path problem in your movie...

You have defined button_array in the main timeline and you are calling it within the movieclip without any indicaiton where that button_array exists...

You will have to replace all the 'button_array' in the movieclip to be '_root.button_array' or something...

Not sure if that is going to solve your problem or not, but I hope that will at least get you going somewhat further... ;)