Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Dec 2005
    Posts
    217
    Thanks
    1
    Thanked 0 Times in 0 Posts

    whats problem in this code ?

    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";
    //alert(images.length);
    // 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
    Last edited by PHPycho; 07-18-2007 at 05:38 AM.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Remove the var keyword. You are not declaring a variable here. You are setting an array element.
    Code:
    var imageObj[i] = new Image();
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •