Hi gang.
I'm just trying to create a simple example of a 3d object in away3D/
flash. I read the about the texture bug in the original monkey file
and have downloaded the new file and added the
_loader.autoLoadTextures = false; line.
Here's all my code for this simple doc class...
package
{
//away3D imports
import away3d.containers.*;
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.events.*;
import away3d.loaders.*;
import away3d.cameras.*;
//flash imports
import flash.display.*;
import flash.events.*;
[SWF(width="1600", height="1200")]
public class Main extends Sprite
{
//away3D vars
private var _view:View3D;
private var _hoverCamera:HoverCamera3D;
private var _loader:LoaderCube;
//setting vars
private var _swfWidth:uint = 1600;
private var _swfHeight:uint = 1200;
private var _distance:uint = 1000;
private var _panMult:Number = .1;
private var _tiltMult:Number = .02;
public function Main()
{
createView();
createScene();
createCamera();
}
private function createView():void
{
// Create view and add it to the stage
_view = new View3D();
addChild(_view);
//Relocate center point of view to the center of stage
_view.x = _swfWidth * .5;
_view.y = _swfHeight * .5;
//call the view render method on enter frame
addEventListener(Event.ENTER_FRAME, viewRender);
}
protected function createScene():void
{
// Create a new scene containing a trident and two cubes
var scene:Scene3D = new Scene3D();
_loader = new LoaderCube();
_loader.autoLoadTextures = false;
var url : String = "monkey.3ds";
_loader.addEventListener(Loader3DEvent.LOAD_SUCCESS,
onSuccess);
_loader.loadGeometry(url, new Max3DS());
_view.scene.addChild(_loader);
scene.addChild(_loader);
//Assign the new scene to the view
_view.scene = scene;
}
private function onSuccess(evt:Loader3DEvent):void
{
trace("file loaded");
}
protected function createCamera():void
{
_hoverCamera = new HoverCamera3D()
_hoverCamera.distance = _distance;
_view.camera = _hoverCamera;
}
protected function viewRender(evt:Event):void
{
_hoverCamera.panAngle = (stage.mouseX -
stage.stageWidth * .5) *
_panMult;
_hoverCamera.tiltAngle = (stage.mouseY -
stage.stageHeight * .5) *
_tiltMult;
_hoverCamera.hover();
_view.render();
}
}//closes class
}//closes package
I'm getting this error:
TypeError: Error #1009: Cannot access a property or method of a null
object reference.
at away3d.loaders::Loader3D/loadTextures()
at away3d.loaders::Loader3D/onGeometryComplete()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
Any ideas? Does anyone have a simple example of a loaded 3d object
that works?
Thanks!