Reputation: 103
Am trying to build an app using Haxe and CreateJS (externs). I am running into an issue with loading manifests.
Here is the code:
function loadAssets():void
{
var _manifest:String = "assets/manifests/mymanifest.json";
_queue = new LoadQueue(true);
_queue.on("complete", onQueueComplete);
_queue.on("error", onQueueError);
_queue.loadManifest([_manifest]);
}
contents of mymanifest.json:
{
"path" : "assets/images/main_menu/",
"manifest" :
[
{"id" : "mm_background", "src" : "background.jpg", "type":"Image"},
{"id" : "mm_adv_off", "src" : "advanSelectOff.jpg", "type":"Image"},
{"id" : "mm_adv_on", "src" : "advanSelectOver.jpg", "type":"Image"},
{"id" : "mm_tech_off", "src" : "techSelectOff.jpg", "type":"Image"},
{"id" : "mm_tech_on", "src" : "techSelectOver.jpg", "type":"Image"},
{"id" : "mm_app_off", "src" : "appSelectOff.jpg", "type":"Image"},
{"id" : "mm_app_on", "src" : "appSelectOver.jpg", "type":"Image"}
]
}
I notice that mymanifest.json gets loaded, however none of the images get loaded.
onQueueError
does not trigger, so I don't think there is a typo or malformed error...
How I verified:
I look at the console in the browser, and viewed the network load...
console shows no error traces or the sort. Network does not show any loads of the images...
Upvotes: 3
Views: 222
Reputation: 11294
I am fairly certain that your manifest is just getting loaded as JSON, and that there is nothing that identifies it as a manifest.
Force the manifest type
Since you are adding the manifest as an Array with one item, it just interprets it as a plain JSON file (due to the extension). To flag it as a manifest, you can include a type to indicate to PreloadJS that the JSON file is a manifest.
Example:
_queue.loadManifest([
{src: _manifest, type: "manifest"}
]);
OR: Pass the manifest file directly
Pass the manifest as the only argument, instead of an Array containing the manifest. If the loadManifest
method receives one argument, it assumes it is either:
Example:
_queue.loadManifest(_manifest); // No square brackets
That should tell PreloadJS to load the JSON, parse it, check for a manifest
property of the result, and load it.
Upvotes: 1