Closed Thread Icon

Topic awaiting preservation: not sure how to pre-load Pages that link to <a href="https://ozoneasylum.com/backlink?for=8726" title="Pages that link to Topic awaiting preservation: not sure how to pre-load" rel="nofollow" >Topic awaiting preservation: not sure how to pre-load\

 
Author Thread
lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 06-19-2003 07:47

Hello,
http://lgwm.org/o95js/ (->game.htm) . This game plays perfectly if ran from harddisk or using a fast/proxied connection, however on slow connections, everytime I change an image object source the image seems to get reloaded again as if it has never been loaded.

Any tips on how to really make a pre-load for this game?

Thanks!

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 06-19-2003 08:08

No manner of clicking managed to get it to work for me (dialup user here).

Although, there were certainly a lot of little red x's about. Is the game supposed to contain broken images?

Anyways, the boolean property of document.images.imageNameOrID.complete is your best friend when preloading images.

lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 06-19-2003 08:44

Hi Dracusis,

download the zipped version and run it from your harddisk and compare its behaviour:
http://lgwm.org/o95js/o95js.zip


I am not really going to check for .complete ...I was thinking of a for loop in the beginning of my script to have all the images loaded in an image array then later instead of loading the image as: myImage.src = 'xyz.gif' I do: myImage.src = imgArray[n].src;

I don't know if the way I described is the way to pre-load images.

amikael
Bipolar (III) Inmate

From: övik
Insane since: Dec 2002

posted posted 06-20-2003 01:13

You can check this game out for an example of a preload in IE5x. http://www.naltabyte.se/space/files/angel.htm

(^-^)b

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 06-20-2003 07:21

Not going to check for .complete?

Then how do you intend to know if the images have loaded or not?

I mean, if the program won't work because the images haven't loaded then, well, your kinda have to check the complete boolean.

Creating an image object (myVar = new Image() ) then setting a source (myVar.src = path/image.jpg) will start to load that image into the browser cache but if you use an <img> tag for that image before it's loaded then it's all for nothing as it will send a second request for that data. This is also why you should have well formed HTML as from what I've seen, when a browser need to load content before it can continue reading the HTML, it sometimes doubles up on loading data that is already being transferred. I suspect this is because the browser reads as much of the HTML as it can and then it consolidates any identical requests before they are sent.

Actually, now I think about this a little more. I might be wrong with the doucment.images.myImageName.complete thing. You might have to check it as myImageObject.complete but either way, the .complete boolean is the key to preloading images with JavaScript. Without it you might be causing the browser to load the same data twice, but I could be wrong on that. In any event, it makes sense to check if an image is loaded if you need it to be loaded for the game to function does it not?

[This message has been edited by Dracusis (edited 06-20-2003).]

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 06-20-2003 12:17

lallous: Have you checked out the FAQ on this?:

:FAQ:

___________________
Emps

FAQs: Emperor

« BackwardsOnwards »

Show Forum Drop Down Menu