jeffcool
02-26-2004, 03:51 PM
don't know if this is a newbie question, or I'm just doing something stupid.. but what I have is a function that has a loop in it that created an array.
this.onLoad = make_Array;
function make_Array() {
X = 5;
var my_Array:Array = new Array();
for (n=0; n<X; n++) {
my_Array[n] = n;
}
//show the array I just created
trace("Display Array:");
for (n=0; n<X; n++) {
trace(my_Array[n]);
}
}
//now outside the loop I want to show it again
trace("Display Array Again:");
for (n=0; n<X; n++) {
trace(my_Array[n]);
}
my output in the trace window is:
Display Array Again:
Display Array:
0
1
2
3
4
Why does the second display get done before the first?
this.onLoad = make_Array;
function make_Array() {
X = 5;
var my_Array:Array = new Array();
for (n=0; n<X; n++) {
my_Array[n] = n;
}
//show the array I just created
trace("Display Array:");
for (n=0; n<X; n++) {
trace(my_Array[n]);
}
}
//now outside the loop I want to show it again
trace("Display Array Again:");
for (n=0; n<X; n++) {
trace(my_Array[n]);
}
my output in the trace window is:
Display Array Again:
Display Array:
0
1
2
3
4
Why does the second display get done before the first?