|
|
Author |
Thread |
Ensabanur
Bipolar (III) Inmate
From: KY Insane since: Nov 2001
|
posted 12-06-2001 21:43
can anyone tell me what's wrong with this code
_____________
function backdrop()
{
var start=1;
x=75;
y=955;
while(start == 1)
{
leftbackdrop.style.left=x;
rightbackdrop.style.left=y;
x++;
y++;
if(x>=325 && y>=1105)
{
x=75;
y=955;
}
}
}
______________
it keeps freezing my browser
Hello! My name is Indigo Montoya... You kill my father... Prepare to DIE!!
|
InI
Paranoid (IV) Mad Scientist
From: Somewhere over the rainbow Insane since: Mar 2001
|
posted 12-06-2001 22:12
The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.
|
bitdamaged
Maniac (V) Mad Scientist
From: 100101010011 <-- right about here Insane since: Mar 2000
|
posted 12-06-2001 22:18
the short answer is your while loop is infinite "start" never changes.
Gonna cause lots problems with something like that
:[ Computers let you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila. ]:
|
Ensabanur
Bipolar (III) Inmate
From: KY Insane since: Nov 2001
|
posted 12-06-2001 23:14
well I got it to work, but it's so fast that I don't see it at all.
Hello! My name is Indigo Montoya... You kill my father... Prepare to DIE!!
|
Bugimus
Maniac (V) Mad Scientist
From: New California Insane since: Mar 2000
|
posted 12-06-2001 23:30
Ensabanur, that is precisely why you need to specify a time interval for that movement function.
You can either use setTimeout() to call the same function by placing it as the last line of the function:
setTimeout( "moveMydiv()", 50 )
or you can use setInterval() once to have the function called repeatedly:
setInterval( "moveMydiv()", 50 )
|
Ensabanur
Bipolar (III) Inmate
From: KY Insane since: Nov 2001
|
posted 12-07-2001 00:38
I've done that, and how it stalls the browser.
_____________
function backdrop()
{
var start
start=1;
x=75;
y=955;
while(start == 1)
{
leftbackdrop.style.left=x;
rightbackdrop.style.left=y;
x--;
y++;
if(x>=325 && y>=1105)
{
start=0;
x=75;
y=955;
}
}
var timer = setTimeout("backdrop()","10000");
}
_____________________________
Hello! My name is Indigo Montoya... You kill my father... Prepare to DIE!!
|
Bugimus
Maniac (V) Mad Scientist
From: New California Insane since: Mar 2000
|
posted 12-07-2001 01:25
Do *not* put your time in double quotes. And the way you're using this you don't need to assign this to a timer variable. Try this and see if it works better:
setTimeout("backdrop()", 50)
I put 50 milliseconds instead of 10000 milliseconds because 10000 milliseconds = 10 seconds and I really don't think you want to wait that long between each move.
I hope that helps.
|
Ensabanur
Bipolar (III) Inmate
From: KY Insane since: Nov 2001
|
posted 12-07-2001 01:28
nope, the program freezes every time I try to run it
Why could be making it do that?
Hello! My name is Indigo Montoya... You kill my father... Prepare to DIE!!
|
Bugimus
Maniac (V) Mad Scientist
From: New California Insane since: Mar 2000
|
posted 12-07-2001 03:53
At this point I can't help you without seeing the page. Could you post a link?
|
bitdamaged
Maniac (V) Mad Scientist
From: 100101010011 <-- right about here Insane since: Mar 2000
|
posted 12-07-2001 04:13
Still infinite loop.
If it runs at all it'll eventually kill the buffer.
The set timeout is even making things worse in this case since it starts even more infinite loops.
You need the setTimeout in an if statement.
Get rid of the while loop.
:[ Computers let you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila. ]:
[This message has been edited by bitdamaged (edited 12-07-2001).]
|
Bugimus
Maniac (V) Mad Scientist
From: New California Insane since: Mar 2000
|
posted 12-07-2001 04:54
Thanks, bit, I glossed right over the loop in there.
I think this is closer to what you need:
code:
var start
start=1
x=75
y=955
function backdrop()
{
leftbackdrop.style.left=x
rightbackdrop.style.left=y
x--
y++
if(x>=325 && y>=1105)
{
start=0
x=75
y=955
}
setTimeout("backdrop()",50)
}
[This message has been edited by Bugimus (edited 12-07-2001).]
|
Ensabanur
Bipolar (III) Inmate
From: KY Insane since: Nov 2001
|
posted 12-07-2001 19:52
Thanks a lot guys, I got it working. It doesnt' look that bad I think. You can check it out and the other things I've done here
Thanks again guys, your help is much appreciated.
And I'm sure i'll be asking for more at some point.
Hello! My name is Indigo Montoya... You kill my father... Prepare to DIE!!
|
Bugimus
Maniac (V) Mad Scientist
From: New California Insane since: Mar 2000
|
posted 12-07-2001 20:09
Nice wave! I wrote a similar function that uses a landscape scrolling by: http://bugimus.com/gurus/panorama/panorama.html
Wakkos also did something similar on his page: http://www.wakkos.f2s.com/
|
zoran
Bipolar (III) Inmate
From: Sarajevo, Bosnia Insane since: Dec 2001
|
posted 12-11-2001 17:15
Nice work. May I steal this scripts?
code:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello World!";
|
Pugzly
Paranoid (IV) Inmate
From: 127.0.0.1 Insane since: Apr 2000
|
posted 12-11-2001 18:14
Bugimus - VERY COOL!
I've got an idea........
|
Bugimus
Maniac (V) Mad Scientist
From: New California Insane since: Mar 2000
|
posted 12-11-2001 19:30
zoran,
You may not "steal" them but you can certainly "learn and use" them
I think most of the coders around here let people use their code but they like to have some recognition as a thank you. I put this comment in my code to remind people. And if you come up with something really cool, please share it with us so we can all benefit.
/*
Written by Bugimus
Copyright © 1998-2001 Bugimus, all rights reserved.
You may use this code for your own *personal* use provided you leave this comment block intact.
A link back to Bugimus' page would be much appreciated. http://bugimus.com/
*/
|
zoran
Bipolar (III) Inmate
From: Sarajevo, Bosnia Insane since: Dec 2001
|
posted 12-12-2001 10:41
I was thinking about this, I will give you credits if I use your scripts. I just wanted to point it out, if somebody forget to do it.
code:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello World!";
|
Petskull
Maniac (V) Mad Scientist
From: 127 Halcyon Road, Marenia, Atlantis Insane since: Aug 2000
|
posted 12-13-2001 09:58
well.... I'd hafta say no.....
and that's on accounta..... with the exception of the absence of a coma after the 'Hello' that's the exact first script I wrote in Perl! It's mine!
....then again, I think that also goes for 20 million people too... hehhee
my first page, BASIC code, C code, and first example of div movement all said "Hello, World!"
hehhehe
something I picked up somewhere..... kinda like "All your base are belong to us"...
"A kleptomaniac is a person who helps himself because he can't help himself." --Henry Morgan
ICQ: 67751342
|
Arthemis
Paranoid (IV) Inmate
From: Milky Way Insane since: Nov 2001
|
posted 12-16-2001 15:08
"in the beggining my programs would come out and say "hello world!", now all that they say is "eat me"" <- famous words
|