View Full Version : preload fotos
alaios
09-28-2002, 10:22 AM
http://www.evridikifans.gr/match/
in this url u can find a little game.....please see the code ,,,and try to preload the fotos before the player starts playing....
Something else onload event means when i read the code of a page , or when everything is transferred succesfully in to my pc such photos videos etc.
thx!!!
redhead
09-28-2002, 12:11 PM
there are some image preloaders at http://www.javascriptkit.com/script/cutindex4.shtml
:thumbsup:
erm... if the general intention of this post is for poeple to see your script then thats fine, but if its asking about the preloader then this isnt the right forum...
alaios
09-28-2002, 03:27 PM
thx but this does not help...pla moderator move my post in to the correct place...thx
Is this any good to you?
<script language="JavaScript">
<!--
var YourImages = new Array("pic1.gif","pic2.gif","pic3.gif","pic4.gif","pic5.gif","pic6.gif")// list images to preload
var preloadYourImages=new Array() // preloads images
for (i=0;i<=YourImages.length-1;i++) {
preloadYourImages[i]=new Image()
preloadYourImages[i].src=YourImages[i]
}
// -->
</script>
alaios
09-28-2002, 06:31 PM
but the user can start playing before all the fotos are completed loaded!!so i must do something for this ..I want to preload all the fotos and then let the user to play the game.....
firstly i hide thw window and with an onload event i was bringing again the window in to the screennn....but it doesnot work
adios
09-28-2002, 06:53 PM
Before you assign the .src, set an onload handler on each preload Image object:
tile[((s-1)*tiles)+t].onload = function() {--unloaded};
tile[((s-1)*tiles)+t].src = 'images/'+s+'_'+t+'.gif';
All you need is a global variable unloaded, initialized to the number of images to be preloaded; you can use this as a flag to prevent user input until unloaded = 0.
alaios
09-28-2002, 06:56 PM
can u explain plz?something more?
adios
09-28-2002, 07:06 PM
var unloaded = howmany;
function preload() {
if (document.images) {
tile = new makeArray(tiles * sets + 1);
tile[0].src= 'images/tileup.gif';
for (var s = 1; s <= sets; s++) {
for (var t = 1; t <= tiles; t++) {
tile[((s-1)*tiles)+t].onload = function() {--unloaded};
tile[((s-1)*tiles)+t].src = 'images/'+s+'_'+t+'.gif';
}
}
..........etc........
function select(pos) {
if (!running || unloaded) return;
Just a wild guess; not enough time to really look at this.
alaios
09-28-2002, 08:44 PM
!
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.