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.
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.