View Full Version : whats problem in this code ?

07-18-2007, 05:27 AM
Hello forums!!
I am using this code for preloading images

var images = new Array();
var i = 0;
images[0] = "img/image1.gif";
images[4] = "img/image5.gif";
// start preloading..
for(i = 0; i < images.length; i++){
var imageObj[i] = new Image();
imageObj[i].src = images[i];
and following error occurs (in firebug)

missing ; before statement
[Break on this error] var imageObj[i] = new Image(); \n
Any Idea where i went wrong ..
thanks in advance to all of you

07-18-2007, 06:01 AM
Remove the var keyword. You are not declaring a variable here. You are setting an array element.

var imageObj[i] = new Image();