It's because you haven't initiated your view3D and Scene3D
you need to stick in:
scene = new Scene3D;
view = new View3D({scene:scene,camera:hoverCamera});
after you initiate the camera, then get rid of the view.camera =
hoverCamera line, you don't need it.
On Feb 6, 7:07 pm, Guha <[email protected]> wrote:
> I am trying to create the 3D layout in MXML using the code below and I
> get an error
> Error #1009: Cannot access a property or method of a null object
> reference.
> at A3DL_Primitives/appComplete()[C:\Documents and Settings\guha\Adobe
> Flash Builder 4\testing3dlite\src\A3DL_Primitives.mxml:40]
> at A3DL_Primitives/
> ___A3DL_Primitives_Application1_applicationComplete()[C:\Documents and
> Settings\guha\Adobe Flash Builder 4\testing3dlite\src
> \A3DL_Primitives.mxml:8]
>
> I suspect this must be because view(line40) and scene are not
> recognized for the base screen- not clear where I am going wrong-
> appreciate insights
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application
> xmlns:mx="http://www.adobe.com/2006/mxml"
> layout="absolute"
> applicationComplete="appComplete()"
> width="480"
> height="384"
> frameRate="100">
> <mx:Script>
> <![CDATA[
> import away3dlite.containers.Scene3D;
> import away3dlite.containers.View3D;
> private var applicationManager:ApplicationManager =
> null;
> import away3dlite.cameras.HoverCamera3D;
> import away3dlite.core.base.Mesh;
> import away3dlite.core.utils.*;
> import away3dlite.loaders.*;
> import away3dlite.materials.*;
> import away3dlite.primitives.*;
> import away3dlite.templates.*;
>
> private function appComplete():void
> {
> var applicationManager:FastTemplate = new
> FastTemplate();
> this.addChild(new
> SpriteUIComponent(applicationManager));
> [Embed(source="../media/texture.jpg")]
> const ModelTex:Class;
>
> var mesh:Mesh = null;
> var texture:BitmapMaterial = null;
> var hoverCamera:HoverCamera3D = null;
> var view:View3D;
> var scene:Scene3D;
> texture = new
> BitmapMaterial(Cast.bitmap(ModelTex));
> texture.smooth = true;
> hoverCamera = new HoverCamera3D(10, 100,
> mesh, 1000);
> view.camera = hoverCamera;
> if (mesh != null)
> { scene.removeChild(mesh); mesh
> = null;}
>
> mesh = new Cube6(texture, 10, 10, 10);
> scene.addChild(mesh);
> }
>
> ]]>
> </mx:Script>
>
> </mx:Application>