AssetLibrary loading help

Software: Away3D 4.x

Ankur, Jr. Member
Posted: 24 January 2013 06:20 PM   Total Posts: 43

There is something wrong in the onModelLoadComplete function.
After commenting out certain stuff, I have figured that there is some problem with these lines (look at the comments in source code).
But I can not figure out what exactly the problem is.

It does not give any error but the model does not load.

Also note that the model is working as I used a Loader3D to load it before and managed to add it succesfully to the scene using addChild(_loader) funtion. But I decided to use AssetLibrary but now I do not know how to add the .awd model to the stage.

private function iniObjects():void
  {  
   AssetLibrary
.enableParser(AWD2Parser);
   
AssetLibrary.addEventListener(AssetEvent.ASSET_COMPLETEonAssetComplete);
   
AssetLibrary.addEventListener(LoaderEvent.RESOURCE_COMPLETEonModelLoadComplete);
   
AssetLibrary.addEventListener(LoaderEvent.LOAD_ERRORonModelLoadError);
   
AssetLibrary.load(new URLRequest('myModel2.awd'));
  
}

private function onModelLoadComplete(ev:LoaderEvent) : void
  {
   AssetLibrary
.removeEventListener(AssetEvent.ASSET_COMPLETEonAssetComplete);
   
AssetLibrary.removeEventListener(LoaderEvent.RESOURCE_COMPLETEonModelLoadComplete);
   
AssetLibrary.removeEventListener(LoaderEvent.LOAD_ERRORonModelLoadError);
   
_container = new ObjectContainer3D();
   
_mesh2 AssetLibrary.getAsset('myModel2') as Mesh//POSSIBLE ERROR
   
_container.addChild(_mesh2);//POSSIBLE ERROR
   
_view.scene.addChild(_container);
  

 

   

Ankur, Jr. Member
Posted: 24 January 2013 07:29 PM   Total Posts: 43   [ # 1 ]

solved it.

//had to write this in AssetCompete listener
_mesh2 e.asset as Mesh;

//instead of this in LoadComplete listener

 
_mesh2 AssetLibrary.getAsset('myModel2') as Mesh
   

bart_the_13th, Newbie
Posted: 25 January 2013 02:05 AM   Total Posts: 14   [ # 2 ]

try using this to load the model:

AssetLibrary.load(new URLRequest('myModel2.awd'), 'myModel2'); //assign a name to the model 

[EDIT]
And this to get the asset

_mesh2 AssetLibrary.getAsset('myModel2@mesh') as Mesh//@mesh for mesh, @animationSet for animationSet etc... 

 

   

Ankur, Jr. Member
Posted: 25 January 2013 12:42 PM   Total Posts: 43   [ # 3 ]
bart_the_13th - 25 January 2013 02:05 AM

try using this to load the model:

AssetLibrary.load(new URLRequest('myModel2.awd'), 'myModel2'); //assign a name to the model 

[EDIT]
And this to get the asset

_mesh2 AssetLibrary.getAsset('myModel2@mesh') as Mesh//@mesh for mesh, @animationSet for animationSet etc... 

no, it does not work. AssetLibrary.load() expects an assetLoaderContext for the second arguement, but for the third arguement it expects ns:String.

Is ns:String the name you are talking about?

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X