Enjoy an ad free experience by logging in. Not a member yet?
Register .
08-04-2002, 07:20 PM
PM User |
#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
08-04-2002, 08:52 PM
PM User |
#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
08-04-2002, 09:16 PM
PM User |
#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
08-04-2002, 09:18 PM
PM User |
#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.
08-04-2002, 09:30 PM
PM User |
#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
08-04-2002, 09:37 PM
PM User |
#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')
08-04-2002, 09:58 PM
PM User |
#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
08-04-2002, 10:06 PM
PM User |
#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);
}
08-04-2002, 10:09 PM
PM User |
#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);
}
08-04-2002, 10:17 PM
PM User |
#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
08-04-2002, 10:22 PM
PM User |
#11
Regular Coder
Join Date: Jun 2002
Posts: 624
Thanks: 0
Thanked 0 Times in 0 Posts
Maybe this?
animation=setTimeout('GoTo(id)',50);
}
08-04-2002, 10:28 PM
PM User |
#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
08-04-2002, 10:39 PM
PM User |
#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
08-04-2002, 10:41 PM
PM User |
#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
08-04-2002, 10:41 PM
PM User |
#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?
Jump To Top of Thread
Thread Tools
Rate This Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT +1. The time now is 06:19 PM .
Advertisement
Log in to turn off these ads.