0

如何控制 Flash CC HTML5 Canvas 中的资源加载?所以 1 spritesheet 首先加载并播放,然后下一个可以加载?

4

1 回答 1

0

使用来自 CreateJS cdn 的 PreloadJS

var imagesReady = false;

// Here are your assets in a nice manifest
var preloadJSmanifest = [{
    src: "1.png",
    id: "1headline"
}, {
    src: "2.png",
    id: "2"
}, {
    src: "3.png",
    id: "3"
}, {
    src: "4.png",
    id: "4cta"
}, {
    src: "5.png",
    id: "5"
}, {
    src: "6.png",
    id: "6"
}, {
    src: "7.png",
    id: "7thingname"
}];

function doPreloadGrfx() {

    // create preload
    queue = new createjs.LoadQueue(true);

    queue.on("progress", handleProgress);
    queue.on("complete", handleComplete);
    queue.on("fileload", handleFileLoad);
    queue.loadManifest(preloadJSmanifest, true, "assets/");

}

function handleFileLoad(event) {

    var image = event.result;
    var w = image.width;
    var h = image.height;

}

function handleComplete(event) {

    imagesReady = true;
    checkAllAssetsLoaded();
}

function checkAllAssetsLoaded() {

    if (imagesReady) {

        console.log("imagesReady");
        drawGraphicsNextThing();

    }
}
于 2015-02-23T01:40:40.557 回答