| checking preloads.... JS gurus welcome! |
mipapage

msg:1475926 | 9:24 am on Apr 25, 2003 (gmt 0) | Hello, A while back I stumbled across a bit of script that I could add to my preloader that would check and see if the images were actually preloading. It would pop-up an alert box when all of the preloading was finished. Being the clever person I am, I seem to have *cough* 'lost' that bit of script. I have searched high and low, but I have been unsuccessful at locating it on the web again. It went something like this:
function preLoad() { image01 = new Image(); image01.onload = loadCheck; image01.src = "images/aticob.jpg"; image02 = new Image(); image02.onload = loadCheck; image02.src = "images/primerb.jpg"; }}
This bit of code is missing something though. Namely what to do with the loadcheck data, and popping up the alert box. I am a JS rookie at best, although like many, I can hack together what I need, but this is evading me. Can anyone help me out with this?
|
RonPK

msg:1475927 | 1:22 pm on Apr 25, 2003 (gmt 0) | I guess you could make the function loadCheck count until it reaches the number of images you're preloading:
var count = 0; function loadCheck() { count++; if(count == 5) { alert("I'm ready!"); } } function preLoad() { image01 = new Image(); image01.src = "images/aticob.jpg"; image01.onload = loadCheck(); // et cetera }
Please note I haven't tested this...
|
mipapage

msg:1475928 | 7:26 pm on Apr 25, 2003 (gmt 0) | That was it. I'll try it and go from there. Thanks, I just don't trust preloaders on there own when designing!
|
|
|