HTML and CSS Reference
In-Depth Information
assetsRemaining = assetsTotal;
// Closure'd per-asset callback gets called
// each time an asset is successfully loadded
var loadedCallback = function(key,obj) {
if(errors) return;
// Add the object to our asset list
Q.assets[key] = obj;
// We've got one less asset to load
assetsRemaining--;
// Update our progress if we have it
if(progressCallback) {
progressCallback(assetsTotal - assetsRemaining,assetsTotal);
}
// If we're out of assets, call our full callback
// if there is one
if(assetsRemaining === 0 && callback) {
// if we haven't set up our canvas element yet,
// assume we're using a canvas with id 'quintus'
callback.apply(Q);
}
};
// Now actually load each asset
_.each(assetObj,function(itm,key) {
// Determine the type of the asset
var assetType = Q.assetType(itm);
// If we already have the asset loaded,
// don't load it again
if(Q.assets[key]) {
loadedCallback(key,Q.assets[key]);
} else {
// Call the appropriate loader function
// passing in our per-asset callback
// Dropping our asset by name into Q.assets
Q["loadAsset" + assetType](key,itm,
loadedCallback,
function() { errorCallback(itm); });
}
});
Search WWH ::




Custom Search