Hey I have a problem…When I load a .3Ds file it loads perfectly. However when I change the parser to .obj or .awd I get an error with No parser….I have enabled all parsers and it still does not work… Please help. Also if you could suggest a good tutorial for AWD 4.0 for loading files and do not suggest the one on adobe forum because that does not load…Thanks
Here is the code I am trying to get to work for other files (besides 3DS):
package
{
import away3d.deep.*;
import away3d.cameras.lenses.PerspectiveLens;
import away3d.containers.ObjectContainer3D;
import away3d.containers.View3D;
import away3d.entities.Mesh;
import away3d.events.LoaderEvent;
import away3d.loaders.Loader3D;
//import away3d.loaders.parsers.Max3DSParser;
import away3d.loaders.parsers.*;
import away3d.loaders.parsers.Parsers;
import away3d.*;
import away3d.materials.ColorMaterial;
import away3d.materials.TextureMaterial;
import away3d.textures.BitmapTexture;
import flash.display.Bitmap;
import flash.display.MovieClip;
import flash.display.Shape;
import flash.display.SimpleButton;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.MouseEvent;
import flash.events.SecurityErrorEvent;
import flash.geom.Vector3D;
import flash.net.FileFilter;
import flash.net.FileReference;
import flash.net.URLRequest;
import flash.system.Security;
import flash.text.TextField;
// 3DS Model Viewer Tutorial
// by Vu Hoang Minh - www.3dgameflash.com
// Created for active.tutsplus.com
public class Main extends Sprite
{
private var file:FileReference;
private var view3d:View3D;
private var loader:Loader3D;
private var labelDebug:TextField;
private var object3d:Mesh;
public function Main():void
{
if (stage)
init();
else
addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
//allow all domain for load local file
Security.allowDomain("*");
removeEventListener(Event.ADDED_TO_STAGE, init);
//3d engine
view3d = new View3D();
view3d.camera.lens = new PerspectiveLens();
view3d.camera.z = 100;
addChild(view3d);
//init 3d loader
initLoader();
//mcBrowse
var mcBrowse:MovieClip = new MovieClip();
mcBrowse.graphics.beginFill(0xeeeeee);
mcBrowse.graphics.drawRoundRect(1, 2, 100, 25, 7, 7);
mcBrowse.graphics.endFill();
var labelBrowse:TextField = new TextField();
labelBrowse.text = "Browse";
mcBrowse.addChild(labelBrowse);
mcBrowse.mouseChildren = false;
mcBrowse.buttonMode = true;
labelBrowse.x = 25;
mcBrowse.addEventListener(MouseEvent.CLICK, onClick_mcBrowse);
addChild(mcBrowse);
//debug label
labelDebug = new TextField();
labelDebug.text = "...";
labelDebug.textColor = 0xff0000;
labelDebug.selectable = false;
labelDebug.y = mcBrowse.height / 2;
labelDebug.width = 600;
addChild(labelDebug);
//file
file = new FileReference();
}
private function initLoader():void
{
//clear
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
while (view3d.scene.numChildren > 0)
{
view3d.scene.removeChild(view3d.scene.getChildAt(0));
}
//init new Loader
Parsers.enableAllBundled();
Loader3D.enableParsers(Parsers.ALL_BUNDLED);
//Loader3D.enableParser(Max3DSParser);
loader = new Loader3D();
loader.addEventListener(LoaderEvent.RESOURCE_COMPLETE, onComplete_loader);
//Loader3D.parse( data, null, new AssetLoaderContext(false));
loader.addEventListener(LoaderEvent.LOAD_ERROR, onError_loader);
view3d.scene.addChild(loader);
view3d.camera.lookAt(loader.position);
}
private function onClick_mcBrowse(e:MouseEvent):void
{
trace("on click");
file.browse();//[new FileFilter("3DS", "*.3ds")]
file.addEventListener(Event.SELECT, onFileSelected);
file.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);
file.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
}
private function onSecurityError(e:Event):void
{
trace("security Error");
labelDebug.text += ".Security Error!";
}
private function onIOError(e:IOErrorEvent):void
{
trace("IO ERROR");
labelDebug.text += ".File not found Error!";
}
private function onFileSelected(e:Event):void
{
trace("On File Selected");
labelDebug.text = "File :" + file.name;
file.removeEventListener(Event.SELECT, onFileSelected);
file.addEventListener(Event.COMPLETE, onFileLoaded);
file.load();
}
private function onFileLoaded(e:Event):void
{
trace("on file loaded");
file.removeEventListener(Event.COMPLETE, onFileLoaded);
initLoader();
loader.loadData(e.target.data);
}
private function onError_loader(e:LoaderEvent):void
{
trace("Error loading File...");
labelDebug.text += " .Loading Error";
}
private function onComplete_loader(e:LoaderEvent):void
{
trace("3D File loaded");
labelDebug.text += " .Complete.Rendering...";
loader.removeEventListener(LoaderEvent.RESOURCE_COMPLETE, onComplete_loader);
loader.removeEventListener(LoaderEvent.LOAD_ERROR, onError_loader);
object3d = Mesh(loader.getChildAt(0));
view3d.scene.addChild(object3d);
loader.dispose();
loader = null;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(e:Event):void
{
object3d.yaw(1);
view3d.render();
}
}
}
Thanks for help!!!
When I load .obj file I get this:
Error #3671: Buffer has zero size
When I load .awd file I get this:
Error: No parser defined. To enable all parsers for auto-detection, use Parsers.enableAllBundled()
Also can someone link me to a tutorial for asset library??
“// To load
AssetLibrary.load(new URLRequest(‘path/to/my/file.awd’));
// Once load has finished
var mesh : Mesh = Mesh(AssetLibrary.getAsset(‘nameOfMyMesh’));”