In the book it give me this piece of code:
package
{
import away3d.containers.View3D;
import away3d.lights.PointLight3D;
import away3d.materials.BitmapMaterial;
import away3d.materials.WhiteShadingBitmapMaterial
import away3d.primitives.Cube;
import away3d.primitives.Sphere;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.events.Event;
public class MyFirstApp extends Sprite
{
private var view : View3D;
private var sphere : Sphere;
public function MyFirstApp()
{
view = new View3D();
view.x = 200;
view.y = 200;
addChild(view);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
var bmp : BitmapData = new BitmapData(200,200);
bmp.perlinNoise(200, 200, 2, Math.random(), true, true);
var mat : BitmapMaterial = new BitmapMaterial(bmp);
var cube : Cube = new Cube();
cube.material = mat;
view.scene.addChild(cube);
var sphere : Sphere = new Sphere();
view.camera.z = -50;
sphere.segmentsW = 32;
sphere.segmentsH = 32;
sphere.material = new WhiteShadingBitmapMaterial(bmp);
sphere.x = 200;
view.scene.addChild(sphere);
var light : PointLight3D = new PointLight3D();
light.y = 500;
view.scene.addLight(light);
}
private function onEnterFrame(ev:Event):void
{
sphere.rotationY += 2;
view.render();
}
}
}
BUT FOR MY SURPRISE..THE SPHERE DOESNT MOVE OR ROTATE AND A OUTPUTE APEAR SAYING ME:
TypeError: Error #1009: No se puede acceder a una propiedad o a un método de una referencia a un objeto nulo.
at MyFirstApp/onEnterFrame()
TypeError: Error #1009: No se puede acceder a una propiedad o a un método de una referencia a un objeto nulo.
at MyFirstApp/onEnterFrame()
Where is the probleme???