SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2002
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    why doesnt this work?

    I have this mouse following script, which does not want to work. Please help me. It doesnt have an error message but does not work the way I intend it to and I cant find the problem with it. Here is the code:



    <html>
    <head>
    <title>Follow that Mouse!</title>
    <script language="JavaScript">

    var blltnum = 7;
    var bllt = new Array(blltnum);
    var Xpos = 0;
    var Ypos = 0;
    var cntr = 0;


    function setup() {
    for (var i = 0; i<blltnum; i++) {


    bllt[i] = document.getElementById("bllt" + i).style;
    bllt[i].left = i * 20;
    bllt[i].top = i * 20;


    }
    animate();
    }

    function getMouse() {
    Xpos = window.event.x;
    Ypos = window.event.y;
    }

    function animate() {

    if (cntr == 0) {
    bllt[cntr].left = Xpos + 5;
    bllt[cntr].top = Ypos + 10;
    }
    else {
    bllt[cntr].left = bllt[cntr-1].left;
    bllt[cntr].top = bllt[cntr-1].top;
    }


    cntr++;

    if (cntr > blltnum - 1) {
    cntr = 0;
    }
    var t = setTimeout("animate();", 10);
    }


    </script>
    </head>
    <body onload="setup();" onmousemove="window.status='X=' + window.event.x + ', Y=' + window.event.y; getMouse();">

    <div ID="bllt0"" style="position:absolute; z-index:10;">
    <img src="pongball1.jpg">
    </div>
    <div ID="bllt1"" style="position:absolute; z-index:9;">
    <img src="pongball1.jpg">
    </div>
    <div ID="bllt2"" style="position:absolute; z-index:8;">
    <img src="pongball1.jpg">
    </div>
    <div ID="bllt3"" style="position:absolute; z-index:7;">
    <img src="pongball1.jpg">
    </div>
    <div ID="bllt4"" style="position:absolute; z-index:6;">
    <img src="pongball1.jpg">
    </div>
    <div ID="bllt5"" style="position:absolute; z-index:5;">
    <img src="pongball1.jpg">
    </div>
    <div ID="bllt6"" style="position:absolute; z-index:4;">
    <img src="pongball1.jpg">
    </div>


    </body>
    </html>

  2. #2
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What exactly is the problem? It works fine in IE6...
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2002
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have IE 5.5 and it hides 5 other balls. It works fine with the 2 balls that follow, but the other 5 balls either arent there or they go directly under the second one so it looks like there are only 2 balls. As far as I can see it looks like it should work fine but it isnt working like it should.

  4. #4
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, admittedly I had no image, but in IE6 it only looked like there was ONE ball!?
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky

  5. #5
    SitePoint Enthusiast
    Join Date
    Feb 2002
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So do you know what the problem is, cause if you did that would be really helpful.

  6. #6
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have played about with it a lot, but unfortunately can't find the solution. Sorry.
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky

  7. #7
    SitePoint Enthusiast
    Join Date
    Feb 2002
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your help anyways, i appreciate it.


Bookmarks

Posting Permissions

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