3

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...

Adam Harte
  • 10,369
  • 7
  • 52
  • 85
MikeH
  • 103
  • 5

1 Answers1

1

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:

  1. An Array of load items (which is what your demo is doing)
  2. A manifest Object (basically the contents of your JSON, but as JavaScript)
  3. A single file path that is a manifest.

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.

Lanny
  • 11,244
  • 1
  • 22
  • 30
  • Thank you Lanny for your help. – MikeH Sep 30 '16 at 13:54
  • I agree with you that I also think the file gets loaded as a JSON only... I attempted the first option (_queue.[oadManifest( [{src:_manifest, type:"manifest"}],true); still gets loaded as a JSON... The second option doesn't seem viable, I get an error stating that loadManifest is looking for a paramter of type Array – MikeH Sep 30 '16 at 13:57
  • Are you using TypeScript or something? loadManifest has always accepted more than just an Array, so the definitions could be wrong. Note that loading as a "manifest" type still loads the file as JSON, but will look for a manifest property once the file is loaded. How are you determining if it is only loading as JSON? – Lanny Sep 30 '16 at 15:30
  • I am not using typescript, but I am using Haxe, with a CreateJS extern. I am guessing the extern's definition might be minimal. I am using createjs2015_11_26_min.js on the page. I think that would be the latest. The way I determine it's loading the file and treating it as a JSON, is that once the file loads, I am able to access it, just like any other JSON...I am guessing that it doesn't see the manifest property...I am not too savvy with breakpoints on web based applications, so I gotta do a little R&D on that, but I think I might be able to get to the bottom of it once I get that in. – MikeH Oct 03 '16 at 13:54
  • will post my findings once. Thank you for staying with me on this. – MikeH Oct 03 '16 at 13:55
  • Well, after a lot of foraging, I have discovered the issue. The Haxelib extern which I got off of the Haxelib site is old, and does not match up completely to what is on the createjs website. Looking at the files listed in the Haxelib extern, there does not exist a ManifestLoader...thus why it defaults to a AbstractLoader,,,Unfortunately though, I don't have time to write up a new "upto-date" extern, so I think I will have to do some hack code to get around this issue...ick... Thank you for the support on this though. – MikeH Oct 04 '16 at 20:17