How does Parcel works? [resolved]

sign up sign in

Hi there,

I decided to use Parcel to load my resources, because I believe is the way to go, but I have an issue.

One option is that I'm misusing it, cause I saw some closed issues related to it, making me believe it's ok.

Other option is that, maybe, I stumbled upon an incomplete implementation.

I tried the Parcel test (source) and it isn't getting the resources, just counting them (am I wrong?).

There's the single_item_complete function, in Parcel class, that I think it should store the Resource in it's particular (typed) list, but I couldn't see it.

I tried:

var img1 = parcel.find("some_image"); //by name  
var img2 = parcel.find_texture("assets/image.png"); //by id

var keys = parcel.textures.keys();  
while (keys.hasNext()) {  
    trace(keys.next());
}

I followed the test source, loading a json, etc.

Nothing works. It seems there's no texture stored.

So, just to mess with it, I just added the following code in single_item_complete:

function single_item_complete( item:Resource ) {

  // my dirty contribution :D
  if (item.type.equals(ResourceType.texture)) {
      textures.set(item.id, cast item);
  }

  ...  //continue
}

Now it works, of course just for textures.

It was just for testing, not considering any design, and I was trying to make textures loading work.

So, what am I doing wrong? Or, is the implementation incomplete?

Thanks!

Tags
helpparcelresource