Loading animated awd model into as3 web app

Software: Away3D 4.x

codedemen, Newbie
Posted: 04 February 2014 12:04 PM   Total Posts: 9

I am trying to lad an awd model, that was made with helpo of this guide.

Ive tryed a lot of different examples on loading awd to a project and now my code to load it into my project looks like this:

Parsers.enableAllBundled();
   
AssetLibrary.enableParser(AWD2Parser);
   
AssetLibrary.addEventListener(AssetEvent.ASSET_COMPLETEonAssetComplete);
   
AssetLibrary.loadData(new TheObject()); 

and the onAssetComplete function:

private function onAssetComplete(event:AssetEvent):void
  {
   MonsterDebugger
.trace("onAssetComplete"event.asset.assetType );
   if (
event.asset.assetType == AssetType.MESH{
    
var staticMesh:Mesh event.asset as Mesh;
    
//staticMesh.geometry.scale(7);
    
_plane.addChild(staticMesh);
   
}
  } 

But it loads only Geometry asset type and never mesh or anything else.
Please help me what am I doing wrong& Im trying to do this for about 8 hours already and just can not understand where is my mistake… Thank you!

P.S: Also attached my awd file.

 

File Attachments
testmodel.awd  (File Size: 1099KB - Downloads: 137)
   

codedemen, Newbie
Posted: 04 February 2014 03:03 PM   Total Posts: 9   [ # 1 ]

Ok, I found a nice loader example, that is working for me. now theis works like:

Parsers.enableAllBundled();
   
AssetLibrary.enableParser(AWD2Parser);
   var 
loader:Loader3D = new Loader3D();
   
loader.addEventListener(LoaderEvent.RESOURCE_COMPLETEonResourceComplete);
   
loader.load(new URLRequest("../embeds/testmodel.awd"));
   
loader.addEventListener(AssetEvent.ASSET_COMPLETEonAssetComplete);
protected function 
onAssetComplete(event:AssetEvent):void
  {
   
if (event.asset.assetType == AssetType.MESH{
    _model 
event.asset as Mesh;
   
}
   
if (event.asset.assetType == AssetType.ANIMATOR{
    _animator 
event.asset as SkeletonAnimator;
    
_animator.play("Idle");
    
_map.addChild(_model);
   
else if (event.asset.assetType == AssetType.ANIMATION_NODE{
    
var node:SkeletonClipNode event.asset as SkeletonClipNode;
    if (
node.name == "Idle"{
     node
.looping true;
    
else {
     node
.looping false;
    
}
   }
  } 
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X