try replacing:
array_name=[];
preload=[];
with:
array_name= new Array();
preload=new Array();
What is the error produced?
MattEvans
Veteran Poster
1,386 posts since Jul 2006
Reputation Points: 522
Solved Threads: 64
ha... the only thing i can think is:
for (var i = 0; i < array_name.length; i++<strong>;</strong>) {
var preload[i] = new Image();
preload[i].src = array_name[i];
}
but hey, i've never seen that last ; put in, and it shouldn't (doesn't need to) be put in really...EDIT: Actually, this seems wrong/uneccessary:
<strong>var</strong> preload[i] = new Image();
preload[i] is already indirectly "var'd" when you make the array.
MattEvans
Veteran Poster
1,386 posts since Jul 2006
Reputation Points: 522
Solved Threads: 64
thats not a local variable; you are assigning index "i", of the inherited scope/routine scope/public scope array "preload" to reference a new Image object, which is automatically var'd and scoped by that assignment (infact, you'll find that Image isn't accessible by any scope; its scope sort of disapears, and it can only be accessed through the array)
If you were doing this:
for (var i = 0; i < array_name.length; i++) {
<strong>var</strong> thisImage = new Image();
thisImage.src = array_name[i];
preload[i] = thisImage;
}
then you'd need (or should use) the var.
MattEvans
Veteran Poster
1,386 posts since Jul 2006
Reputation Points: 522
Solved Threads: 64