469,625 Members | 1,089 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,625 developers. It's quick & easy.

help with setTimeout

cjl
Hey all:

In my script I have the following:

change_opacity (0, id);
for (var x = 0; x<=100; x=x+1)
{
change_opacity( x, id );
}

This works. I want to convert this to a "setTimeout" call, so that it
occurs more slowly. So I try:

change_opacity (0, id);
for (var x = 0; x<=100; x=x+1)
{
setTimeout( "change_opacity(" + x +"," + id + ")", 200 );
}

But it doesn't work. I'm stuck.

-CJL

Oct 23 '05 #1
6 1141
cjl
Hey:

I just found this:

http://groups.google.com/group/comp....505d898bffb1b0

Which sort of explains why I was having a problem.

I re-assigned my 'id' variable to a global, and now things are working.

-CJL

Oct 24 '05 #2
cjl wrote:
Hey all:

In my script I have the following:
[...]

But it doesn't work. I'm stuck.


See manu3d's post below for a much better version.

--
Rob
Oct 24 '05 #3
RobG wrote on 24 okt 2005 in comp.lang.javascript:
See manu3d's post below for a much better version.


What is "below" on usenet, if it is not in your posting?

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 24 '05 #4
JRS: In article <11**********************@g47g2000cwa.googlegroups .com>
, dated Sun, 23 Oct 2005 16:47:47, seen in news:comp.lang.javascript,
cjl <cj****@gmail.com> posted :
Hey all:
Rather ill-mannered - are you an infant Merkin or just a wannabe?
In my script I have the following:

change_opacity (0, id);
for (var x = 0; x<=100; x=x+1)
{
change_opacity( x, id );
}

This works. I want to convert this to a "setTimeout" call, so that it
occurs more slowly. So I try:

change_opacity (0, id);
for (var x = 0; x<=100; x=x+1)
{
setTimeout( "change_opacity(" + x +"," + id + ")", 200 );
}

But it doesn't work. I'm stuck.


I expect it does work; it just does what you told it to do, instead of
what you wanted to so.
Your code sets, as fast as possible, 101 200 ms timeouts. Ideally, 200
ms later, they would all fire in corresponding sequence. In practice,
after about 200 ms, they'll fire probably in either the right order or
possibly the reverse order.

What you should do is to seek some clock code and modify it to not
continue after Number 100. In a clock, each second starts when the
previous one finishes; they do not all start at once. Presumably you
did not read the newsgroup FAQ thoughtfully?

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Oct 24 '05 #5
Evertjan. wrote:
RobG wrote on 24 okt 2005 in comp.lang.javascript:

See manu3d's post below for a much better version.

What is "below" on usenet, if it is not in your posting?


Fair enough. :-x

It was 'below' to me since I like the new stuff at the top and older
stuff at the bottom, but maybe a link would have been better...
--
Rob
Oct 25 '05 #6
cjl
John:
Rather ill-mannered - are you an infant Merkin or just a wannabe?
Did you just call me a pubic hair wig? I guess a reply is in order.
Your mother is a toothless whore.
Your code sets, as fast as possible, 101 200 ms timeouts. Ideally, 200
ms later, they would all fire in corresponding sequence. In practice,
after about 200 ms, they'll fire probably in either the right order or
possibly the reverse order.
I see.
What you should do is to seek some clock code and modify it to not
continue after Number 100. In a clock, each second starts when the
previous one finishes; they do not all start at once.
Now that it a helpful reply, thank you. It seems I should apologize
for sullying the good name of your mother.
Presumably you did not read the newsgroup FAQ thoughtfully?


Hmmm. I tried to read it, but your mother kept begging me for another
shag.

-CJL

Oct 25 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Dennis M. Marks | last post: by
14 posts views Thread by Brandon Hoppe | last post: by
4 posts views Thread by Mool | last post: by
2 posts views Thread by Jackson Yap | last post: by
12 posts views Thread by Andrew Poulos | last post: by
4 posts views Thread by E | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.