By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,630 Members | 1,313 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,630 IT Pros & Developers. It's quick & easy.

Weird behaviour with falling snow script

P: n/a
I'm stumped. I'm playing with a javascript that produces falling snowflakes
on screen. I got the script from this author:
http://thelocust.org/projects/snow2/

If I hotlink to the exploding flake image on the author's site, everything
works as intended: clicking a flake explodes it once, and at some point a
new white flake is produced at the top of the screen to replace the exploded
one.

However, if I save his exploding image to my own web directory and link to
it, as my second test, then clicking a flake causes it to explode
indefinitely in a repeating loop. Bizarre.

Third test, I edited the GIF to not loop it and to end on a blank
transparent frame, so that a flake will explode only once. The problem here
is that after you explode some flakes, they are never replaced by new ones.
No new white flakes appear. In fact, I think the images are still floating,
but it's always the final blank frame of my edited exploding image. Those
are never replaced by the white flake image.

See if you can figure this one out. What I want is the behaviour in Test 1,
but using a local file of the exploding image rather than having to hotlink
to the file off the author's site.

See my tests here: http://public.fiercefocus.com/SnowTests/
Jul 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
VK
As much as I can see the explosion and the flake are two different
pictures.
onClick static flake gif is being replaced/z-overdrawn (have no time to
check) by animated explosion gif. Read instructions with more attention.
Should help...
Jul 20 '05 #2

P: n/a
"VK" <sc**********@yahoo.com> wrote in message
news:3f***********************@news.freenet.de...
As much as I can see the explosion and the flake are two different
pictures.
Yes, I know. I said that in my tests at
http://public.fiercefocus.com/SnowTests/
Read instructions with more attention.
Should help...


Your smug answer doesn't help anyone. As you would see from my tests and my
descriptions on those pages, I did follow the instructions. My Test 1 works
fine, but requires me to hotlink to someone else's file.

The only difference is where the explosion image resides. If I link to the
file on the author's web site, everything works fine. If I link to that same
image saved to my own web directory, it doesn't work properly. There are no
changes to the script other than where that image lives. For some reason it
doesn't work properly if the image sits on my web server or on my PC, but
works if I link to the author's file.
Jul 20 '05 #3

P: n/a
toronto hu kiteb:
"VK" <sc**********@yahoo.com> wrote in message
news:3f***********************@news.freenet.de...
As much as I can see the explosion and the flake are two different
pictures.


Yes, I know. I said that in my tests at
http://public.fiercefocus.com/SnowTests/
Read instructions with more attention.
Should help...

I tried looking at the demo on teh original author's page, and it came
up with a fatal error. I suspect it is the original author who needs
help, not you.
--
--
Fabian
Visit my website often and for long periods!
http://www.lajzar.co.uk

Jul 20 '05 #4

P: n/a
"Fabian" <la****@hotmail.com> wrote in message
news:bs************@ID-174912.news.uni-berlin.de...
I tried looking at the demo on teh original author's page, and
it came up with a fatal error. I suspect it is the original
author who needs help, not you.


That is certainly the case as the script includes:-

snowobj[i] = eval (document.getElementById("flake"+i).style);

-and much else that demonstrates a limited understanding of JavaScript
and browser scripting.

However, the OP's problem is with the line;-

if (document.getElementById('imgflake' + i).src == imgExplode) {

- which compares the src attribute of an image element with the value
assigned to - imgExplode -. But the src attribute of an image element
becomes an absolute URL even when set with a string that represents a
relative URL, as is the case in the examples that use images from the
OP's server, but not when linking to the images on another server as
that URL needs to be absolute anyway. A quick fix would be to change the
test to see if the contents of the - imgExplode - variable was a
substring of the image element src string:-

if(document.getElementById('imgflake'+i).
src.lastIndexOf(imgExplode) >= 0){

Though that would not help with all relative URLs (e.g.
"../../Images/Snow.gif").

It would probably be best to have the script implemented by someone who
know what they were doing.

Richard.
Jul 20 '05 #5

P: n/a

"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message
news:bs*******************@news.demon.co.uk...
That is certainly the case as the script includes:-

snowobj[i] = eval (document.getElementById("flake"+i).style);

-and much else that demonstrates a limited understanding of JavaScript
and browser scripting.

However, the OP's problem is with the line;-

if (document.getElementById('imgflake' + i).src == imgExplode) {

- which compares the src attribute of an image element with the value
assigned to - imgExplode -. But the src attribute of an image element
becomes an absolute URL even when set with a string that represents a
relative URL, as is the case in the examples that use images from the
OP's server, but not when linking to the images on another server as
that URL needs to be absolute anyway. A quick fix would be to change the
test to see if the contents of the - imgExplode - variable was a
substring of the image element src string:-

if(document.getElementById('imgflake'+i).
src.lastIndexOf(imgExplode) >= 0){

Though that would not help with all relative URLs (e.g.
"../../Images/Snow.gif").

It would probably be best to have the script implemented by someone who
know what they were doing.

Richard.


Thanks for checking. I didn't know his script had so many errors.

I don't write javascript, but I want a snow fall effect for an on-line
family card. I searched at some script archives: I found several snow
scripts, but all had defects or errors or choked in modern browsers. This
one seemed to mostly work in modern browsers. This one seems to be pretty
good, if the errors were corrected.

I don't suppose anyone knows where I can find an error-free snowfall script?
Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.