Try:
private function loadOBJ():void {
_objLoader = Obj.load(_objURL, {material:new ColorMaterial
(0xFF0000),
name:"OBJ", scaling:10}); //adjust the scaling as needed
_objLoader.addOnSuccess(onLoaderSuccess);
_objLoader.addOnError(onLoaderError); //create this function
}
Is your onLoaderSuccess dispatched? Or, are you getting onLoaderError
dispatched?
On Jan 4, 11:35 pm, Larry Van Wave <[email protected]> wrote:
> For some reason I'm not getting my object to import, do you have a
> sample file of just a basic import, even if it is without a texture?
>
> Thanks!
>
> 2010/1/4 Paweł Stanisławczuk <[email protected]>:
>
>
>
> > Hi!
>
> > It could be a problem in this line:
> > _mesh = obj.children[0] as Mesh;
>
> > try simple:
> > _mesh = event.target.handle as Mesh;
>
> > You have to "search" for your mesh in event.target.handle
>
> > I needed to add "children[0]" due to my LightWave exporter.
>
> > Paweł
>
> > On Jan 4, 4:46 pm, Larry Van Wave <[email protected]> wrote:
> >> For some reason, when I copy and paste this code into flash, it is
> >> giving me an error on the last function "onLoaderSuccess"
>
> >> Are these the correct lines of code to put in the obj name:
> >> _objLoader = Obj.load(_objURL, {material:_materialObject3D,
> >> name:"OBJ", scaling:10}); //adjust the scaling as needed
>
> >> name:"OBJ" is where I'm adding the name of my lightwave file that I
> >> have exported as an .obj
>
> >> and for my material:
> >> _materialLoader.load(new URLRequest(_materialURL));
>
> >> Thanks!
> >> Larry
>
> >> 2009/12/30 Paweł Stanisławczuk <[email protected]>:
>
> >> > Hi!
>
> >> > Someone can call this method "old school" but it works for me
>
> >> > First I load material, then obj. Import required classes. It's a copy
> >> > paste of 2 different classes, but it should work.
>
> >> > private var _materialLoader:Loader;
> >> > private var _materialObject3D:BitmapMaterial;
> >> > private var _objLoader:Object3DLoader;
> >> > private var _mesh:Mesh;
>
> >> > public function loadMaterial():void {
> >> > _materialLoader = new Loader();
> >> > _materialLoader.contentLoaderInfo.addEventListener(Event.INIT,
> >> > onComplete);
> >> > _materialLoader.contentLoaderInfo.addEventListener
> >> > (IOErrorEvent.IO_ERROR, onMaterialLoaderError);//create this function
> >> > _materialLoader.load(new URLRequest(_materialURL));
> >> > }
>
> >> > private function onComplete(event:Event):void {
>
> >> > _materialLoader.contentLoaderInfo.removeEventListener(Event.INIT,
> >> > onComplete);
> >> > _materialLoader.contentLoaderInfo.removeEventListener
> >> > (IOErrorEvent.IO_ERROR, onMaterialLoaderError);
>
> >> > var bitmap:Bitmap = materialLoader.content as Bitmap;
> >> > bitmap.smoothing = true;
>
> >> > _materialObject3D = new BitmapMaterial(bitmap.bitmapData);
> >> > _materialObject3D.smooth = true;
>
> >> > loadOBJ();
>
> >> > }
>
> >> > private function loadOBJ():void {
> >> > _objLoader = Obj.load(_objURL, {material:_materialObject3D,
> >> > name:"OBJ", scaling:10}); //adjust the scaling as needed
> >> > _objLoader.addOnSuccess(onLoaderSuccess);
> >> > _objLoader.addOnError(onLoaderError); //create this function
> >> > }
>
> >> > private function onLoaderSuccess(event:LoaderEvent):void {
> >> > var obj:ObjectContainer3D = (event.target.handle as
> >> > ObjectContainer3D);
> >> > _mesh = obj.children[0] as Mesh; // I need this trick, I export
> >> > OBJ
> >> > using LightWave
>
> >> > scene.addChild(_mesh);
> >> > }
>
> >> > Good Luck!
> >> > Paweł
>
> >> > On Dec 30, 7:07 pm, Wave3d <[email protected]> wrote:
> >> >> I am a rookie at using away3d, but I like the ability to have a 3d
> >> >> engine using flash. I have tried to load in .obj files, and have
> >> >> looked online for tutorials, yet I haven't found one that will work
> >> >> yet. Do you have any information on the basic code for loading a .obj
> >> >> file into flash using away3d, I'm looking for the bare bones code just
> >> >> so I can understand what elements of code have to be in the
> >> >> actionscript to load the model.