BetaONE will rise again!


Closed Thread
  #1  
Old 20th Dec 03, 08:52 PM
SlickVic78's Avatar
SlickVic78 SlickVic78 is offline
Senior Member
 
Join Date: Sep 2001
Location: New York, USA
Posts: 515
SlickVic78 is an unknown quantity at this point
I wanted to know if there was a way to validate if an image fully preloads before it goes on to the next step within the code... I tried putting in a flag but I don't think it is working...

Preload Function:
Code:
var preloaded = false; function preload() { &nbsp; &nbsp; &nbsp;if (!document.images) return; &nbsp; &nbsp; &nbsp;var ar = new Array(); &nbsp; &nbsp; &nbsp;var arguments = preload.arguments; &nbsp; &nbsp; &nbsp;for (var i = 0; i < arguments.length; i++) { ar[i] = new Image(); ar[i].src = arguments[i]; &nbsp; &nbsp; &nbsp;} &nbsp; &nbsp; &nbsp;preloaded = true; }
Check Preloaded
Code:
function checkpreload(){ &nbsp; &nbsp; &nbsp;if (preloaded){ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;changeImage(); &nbsp; &nbsp; &nbsp;} else { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;newImage = "url(images/gfx_photos/loading_image.gif)"; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;document.getElementById('loading').style.backgroundImage = newImage; &nbsp; &nbsp; &nbsp;} &nbsp; &nbsp; &nbsp;setTimeOut(checkpreload(),1000); }
In the body tag, I have onLoad="preload('imagetoload.jpg');checkpreload(); "

+ So this is what I am wanting this code to do, start to preload an image by calling the preload() function.

+ Next call up the checkpreload() function to see if the image has finished preloading. If so, display the image by calling the changeImage() function. If not fully preloaded, then display a loading image graphic.

+ Every 1 second, call the checkpreload() function to see if the image has preloaded.

The problem, I think, is that the preloaded value is being set to "true" too soon without the image fully preloading...

Is there a way I can validate that the image has preloaded before passing a "true" value to the preloaded variable?

Why am I doing this? Well, for people who have dialup... I want to be able to display the message that an image is loading and then as soon as the image preloads, display it... What happens right now, is that you may get the image loading graphic for a second, then it disappears, you then have to wait an additional 20 seconds before the image actually appears.

Any help would be great!

Thanks!
-SlickVic78
__________________
  • Pentium 4 3.20GHz Processor
  • 1 Gig DDR 400MHz RAM
  • 100 Gig 7200 RPM Western Digital HDD
  • 80 Gig 7200 RPM Western Digital HDD
  • Lite-On LTR-52327S CD-RW Burner
  • Lite-On SOHW-1633S DVD Burner
  • ATI Radeon 9700 Pro
  • Sound Blaster Audigy
  • Microsoft Windows XP Pro SP-2
  #2  
Old 20th Dec 03, 11:11 PM
SlickVic78's Avatar
SlickVic78 SlickVic78 is offline
Senior Member
 
Join Date: Sep 2001
Location: New York, USA
Posts: 515
SlickVic78 is an unknown quantity at this point
Figured it out... I ended up finding a sample source and worked with it to accomplish what I wanted.

Will an Admin or Mod please close this thread.

Thank you,
-SlickVic78
__________________
  • Pentium 4 3.20GHz Processor
  • 1 Gig DDR 400MHz RAM
  • 100 Gig 7200 RPM Western Digital HDD
  • 80 Gig 7200 RPM Western Digital HDD
  • Lite-On LTR-52327S CD-RW Burner
  • Lite-On SOHW-1633S DVD Burner
  • ATI Radeon 9700 Pro
  • Sound Blaster Audigy
  • Microsoft Windows XP Pro SP-2
  #3  
Old 20th Dec 03, 11:58 PM
DoG's Avatar
DoG DoG is offline
Administrator
 
Join Date: Nov 2001
Posts: 2,996
DoG will become famous soon enoughDoG will become famous soon enough
Send a message via ICQ to DoG Send a message via MSN to DoG Send a message via Yahoo to DoG
Closed as requested
__________________

Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:17 AM.


Design by Vjacheslav Trushkin for phpBBStyles.com.
Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.