Problem loading awd file

Software: Away3D 4.x

timd, Newbie
Posted: 07 January 2013 08:36 PM   Total Posts: 5

Hi

Any help would really be appreciated. I’m new to Away3D and trying to load a model. Here is the code I’m using. It is for AIR mobile. Every time the LoaderEvent.LOAD_ERROR event fires. I’ve saved the object as an awd2 file using prefab. The same happens if I save it as a Obj file as well. Any ideas? Any help much appreciated.

Parsers.enableAllBundled(); 
   
loader = new Loader3D(); 
   
loader.addEventListener(LoaderEvent.RESOURCE_COMPLETEonResourceComplete);
   
loader.addEventListener(LoaderEvent.LOAD_ERRORonLoadError); 
   
loader.load( new URLRequest('myModel.awd') );

   
   function 
onResourceComplete(ev LoaderEvent) : void 
   { loader
.removeEventListener(LoaderEvent.RESOURCE_COMPLETEonResourceComplete);
   
loader.removeEventListener(LoaderEvent.LOAD_ERRORonLoadError);
   
view.scene.addChild(loader); }
   
   
function onLoadError(ev LoaderEvent) : void 
   { textbox
.text "No"loader.removeEventListener(LoaderEvent.RESOURCE_COMPLETEonResourceComplete);
   
loader.removeEventListener(LoaderEvent.LOAD_ERRORonLoadError); 
   
loader null
   

Qbrain, Member
Posted: 08 January 2013 02:54 PM   Total Posts: 92   [ # 1 ]

heyy try this (you need to add the imports yourself)

//in your var declaration
[Embed(source="/objects/Object.awd"mimeType="application/octet-stream")private var TheObject:Class;

//in your init function
Parsers.enableAllBundled();
AssetLibrary.addEventListener(AssetEvent.ASSET_COMPLETEonAssetComplete);
AssetLibrary.loadData(new TheObject());

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

timd, Newbie
Posted: 08 January 2013 03:04 PM   Total Posts: 5   [ # 2 ]

Thanks so much, it worked!

   

timd, Newbie
Posted: 17 January 2013 08:35 PM   Total Posts: 5   [ # 3 ]

Another question related to the first. This may seem straightforward but I’m still new to Away3d.

How do I now load two different 3d meshes rather than one using the code above?

Thanks in advance.

   

Avatar
loth, Sr. Member
Posted: 18 January 2013 12:15 AM   Total Posts: 236   [ # 4 ]

use name of mesh
if (event.asset.assetType == AssetType.MESH) {
  var mesh:Mesh = event.asset as Mesh;
  if (mesh.name==“youpla”) yourMesh01 = mesh;
  if (mesh.name==“bla”) yourMesh02 = mesh;
}

   

Qbrain, Member
Posted: 18 January 2013 04:27 PM   Total Posts: 92   [ # 5 ]

what Loth says. I use the exact same way.

-Q

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X