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.
Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    New Coder
    Join Date
    Jun 2002
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help with animation function

    Everytime i run this code through, i get a line 66 character 1 object expected error. i have NO idea what it is. Please help!

    var currentstate=1;

    function GoTo(id)
    {
    var howfar;
    var way;
    if (id > currentstate)
    { howfar=id-currentstate; way="right"; } else { howfar=currenstate-id; way="left"; }
    var distance;
    var result;
    switch (way) {
    case "right"
    distance=howfar*75;
    result=document.getElementById(selector).style.left+distance;
    break;
    case "left"
    distance=howfar*75;
    result=document.getElementById(selector).style.left-distance;
    break;
    }

    if(document.getElementById(selector).style.left=result)
    {clearTimeout(animation);animation=0;} else {
    function="GoTo(" + id + ");";
    animation=setTimeout(function,50);}
    }
    Computers are simple for the complex mind, yet complex for the simple mind

  • #2
    New Coder
    Join Date
    Jun 2002
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts
    fixed it up a little, but still get the same error:
    var currentstate=1;

    function GoTo(id)
    {
    var howfar;
    var way;
    if (id > currentstate)
    { howfar=id-currentstate; way="right"; } else { howfar=currenstate-id; way="left"; }
    var distance;
    var result;
    switch (way) {
    case "right"
    distance=howfar*75;
    result=document.getElementById(selector).style.left+distance;
    break;
    case "left"
    distance=howfar*75;
    result=document.getElementById(selector).style.left-distance;
    break;
    }

    if(document.getElementById(selector).style.left=result)
    {clearTimeout(animation);animation=0;} else {
    animation=setTimeout(GoTo,50,id);}
    }
    Computers are simple for the complex mind, yet complex for the simple mind

  • #3
    New Coder
    Join Date
    Jun 2002
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanx for the help, but i get the same error, this time when i click on it.
    by the way, my website is at vip3r.port5.com
    Computers are simple for the complex mind, yet complex for the simple mind

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Posts
    624
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I deleted my reply hoping not to confuse you. I was wrong, all the brackets are there.

  • #5
    New Coder
    Join Date
    Jun 2002
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanx for ur help. now, after a little bit of editing, i get a line 36 character 1 error. any help would be appreciated!

    var currentstate=1;

    function GoTo(id) {
    var howfar;
    var way;
    if (id > currentstate) {
    howfar=id-currentstate; way="right";
    } else {
    howfar=currenstate-id; way="left";
    }
    var distance;
    var result;
    switch (way) {
    case "right":
    distance=howfar*75;
    result=document.getElementById(selector).style.left+distance;
    break;
    case "left":
    distance=howfar*75;
    result=document.getElementById(selector).style.left-distance;
    break;
    }
    if(document.getElementById(selector).style.left=result) {
    clearTimeout(animation);animation=0;
    } else {
    animation=setTimeout(GoTo,50,id);}
    }
    Computers are simple for the complex mind, yet complex for the simple mind

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Posts
    624
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what is "selector"? If it's an element id it should be like this:

    ('selector')

  • #7
    New Coder
    Join Date
    Jun 2002
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok,thanx.
    now that i fixed it, i got a line 43 character 1 error.
    var currentstate=1;

    function GoTo(id) {
    var howfar;
    var way;
    if (id > currentstate) {
    howfar=id-currentstate; way="right";
    } else {
    howfar=currenstate-id; way="left";
    }
    var distance;
    var result;
    switch (way) {
    case "right":
    distance=howfar*75;
    result=document.getElementById('selector').style.left+distance;
    break;
    case "left":
    distance=howfar*75;
    result=document.getElementById('selector').style.left-distance;
    break;
    }
    if(document.getElementById('selector').style.left=result) {
    clearTimeout(animation);animation=0;
    } else {
    animation=setTimeout(GoTo,50,id);}
    }
    Computers are simple for the complex mind, yet complex for the simple mind

  • #8
    Regular Coder
    Join Date
    Jun 2002
    Posts
    624
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just guessing but try this

    animation=setTimeout(GoTo(),50);
    }

  • #9
    Regular Coder
    Join Date
    Jun 2002
    Posts
    624
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Actually I think it should be like this

    animation=setTimeout('GoTo()',50);
    }

  • #10
    New Coder
    Join Date
    Jun 2002
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i need to pass id to GoTo though, otherwise it wouldn't know where to go, right? thanx for ur help!
    Computers are simple for the complex mind, yet complex for the simple mind

  • #11
    Regular Coder
    Join Date
    Jun 2002
    Posts
    624
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Maybe this?

    animation=setTimeout('GoTo(id)',50);
    }

  • #12
    New Coder
    Join Date
    Jun 2002
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i think what u mean is this:
    setTimout("'GoTo(' + id + ');'");
    and nope, still doesn't work
    Computers are simple for the complex mind, yet complex for the simple mind

  • #13
    New Coder
    Join Date
    Jun 2002
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok, i rewrote it so it makes some more sense now. Now it looks like this:

    var wheretogo;
    var whereis;
    function GoTo(id)
    {
    whereis=document.all.selector.offsetLeft;
    var whereisbyid;
    switch(whereis)
    {

    case: 75
    whereisbyid=1;

    case: 150
    whereisbyid=2;

    case: 225
    whereisbyid=3;

    case: 300
    whereisbyid=4;
    }

    if(whereisbyid>id)
    {way="left"}

    wheretogo=id*75;
    var animation=setInterval("GoToPlace();",50);
    }

    function GoToPlace()
    {

    if(wheretogo != whereis)
    { whereis=whereis+1; } else {clearInterval(animation)}

    }
    Computers are simple for the complex mind, yet complex for the simple mind

  • #14
    New Coder
    Join Date
    Jun 2002
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i still get a line 30 character 8 object expected error
    Computers are simple for the complex mind, yet complex for the simple mind

  • #15
    Regular Coder
    Join Date
    Jun 2002
    Posts
    624
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Still just guessing.

    Where does "animation" come in? Is it part of another script?


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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