Created
July 23, 2013 04:15
-
-
Save piyonishi/6059817 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1つの場合 | |
function preloader() { | |
heavyImage = new Image(); | |
heavyImage.src = "sample.jpg"; | |
} | |
// 複数ある場合 | |
function preloader() { | |
// counter | |
var i = 0; | |
// create object | |
imageObj = new Image(); | |
// set image list | |
images = []; | |
images[0] = "sample1.jpg" | |
images[1] = "sample2.jpg" | |
images[2] = "sample3.jpg" | |
images[3] = "sample4.jpg" | |
// start preloading | |
for(i=0; i<images.length; i++) { | |
imageObj.src = images[i]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment