away3d / away3d-core-fp11

Away3D engine for Flash Player 11
http://www.away3d.com
Other
641 stars 276 forks source link

Loader3D.load & AssetLibrary.getInstance bug #31

Closed volzh closed 13 years ago

volzh commented 13 years ago

I tried to use Loader3D and AssetLibrary to caching 3d models. so, I write codes like this.

then asset got null. so i looked in source code a little bit.

in Loader3D.load function,

lib = AssetLibrary.getInstance(_assetLibId); // this _assetLibId variable passes 'null'

and in AssetLibrary.getInstance function, parameter 'key' got 'null' value, and makes new instance like below,

_instances[null] = new AssetLibrary(new SingletonEnforcer());

so finally, though i didn't use any key value, two library keys are made. if 'key' got null, should 'key' be assigned 'default' ?

sorry for poor english.

richardolsson commented 13 years ago

Thanks for reporting and explaining the issue in such detail. This is definitely a bug, and I will fix it straight away!

volzh commented 13 years ago

thanks for your hurry. and one more thing...

even if I assign library key, AssetLibrary.getAsset('someID', 'building') seems to refer AssetLibrary.getAsset('someID', null).

richardolsson commented 13 years ago

I have fixed the original issue.

In your last comment you are using getAsset() incorrectly. The second parameter is a namespace, which is not the same as a library key. Namespaces are used to separate a single library into groups of assets. This lets you load assets with the same name, provided that you load them into separate namespaces. This is not the same as loading them into separate libraries. Most applications will only need a single library.

So, to load something into the "myns" namespace, and then retrieve an asset from this namespace, do this:

AssetLibrary.load(request, null, null, "myns"); // Load AssetLibrary.getAsset('myasset', 'myns'); // Get

If you want to use a separate library, this is what you would do:

AssetLibrary.getInstance('otherlib').load(request); AssetLibrary.getInstance('otherlib').getAsset('myasset');

Closing this issue, as the originally reported bug has been fixed. If you have any other questions regarding the AssetLibrary, please post them to the forum on away3d.com.

Thanks!

volzh commented 13 years ago

Thanks for quick fix.