[Papervision3D] Error to build a Cube

juniovitorino jgvitorino at gmail.com
Tue Nov 27 12:20:37 PST 2007


Hi all, i've a error than i can't solve yet and i'm looking for help.

/**
* Classe para a criação de um Cubo 3D
* Programador: Junio Vitorino
* 27 de Novembro de 2007
**/

package 
{
	import flash.display.Sprite;
	import flash.events.Event;
	import org.papervision3d.objects.Cube;
	import org.papervision3d.materials.MaterialsList;
	import org.papervision3d.materials.ColorMaterial;
	import org.papervision3d.scenes.Scene3D;
	import org.papervision3d.cameras.FreeCamera3D;

	public class criaCubo extends Sprite
	{
		private var __container:Sprite;
		private var __cubo:Cube;
		private var __cena:Scene3D;
		private var __materialList:MaterialsList;
		private var __freeCamera:FreeCamera3D;
		
		public function criaCubo()
		{
			this.construtora3D_fc();
			this.criaCubo_fc();
			this.addEventListener(Event.ENTER_FRAME, buildCena_fc);
		}
		
		private function buildCena_fc(evt:Event):void
		{
			this.__cena.renderCamera(this.__freeCamera);
		}
		
		private function construtora3D_fc():void
		{
			this.__container = new Sprite();
			this.__freeCamera = new FreeCamera3D();
			this.__container.x = stage.stageWidth/2;
			this.__container.y = stage.stageHeight/2;
			this.__cena = new Scene3D(this.__container);
			this.__freeCamera.zoom = 5;
			this.addChild(this.__container);
		}
		
		private function criaCubo_fc():void
		{
			this.__materialList = new MaterialsList
			(
				{
					all:	new ColorMaterial(0x99cc00, 1),
					front:	new ColorMaterial(0x99cc00, 1),
					back:	new ColorMaterial(0x99cc00, 1),
					left:	new ColorMaterial(0x99cc00, 1),
					right:	new ColorMaterial(0x99cc00, 1),
					top:	new ColorMaterial(0x99cc00, 1),
					bottom:	new ColorMaterial(0x99cc00, 1)
				}
			);
			this.__cubo = new Cube(this.__materialList, 250, 250, 250);
			this.__cena.addChild(this.__cubo);
		}	
	}
}

The error is:

DisplayObject3D: null
TypeError: Error #1009: Cannot access a property or method of a null object
reference.
	at criaCubo/::construtora3D_fc()
	at criaCubo$iinit()
	at main$iinit()
	at cameraRotation_fla::MainTimeline/cameraRotation_fla::frame1()

Someone can see where i'm erring.


-----
Junio Vitorino
Brazil - Belo Horizonte
http://www.juniovitorino.com
jgvitorino at gmail.com
-- 
View this message in context: http://www.nabble.com/Error-to-build-a-Cube-tf4884188.html#a13979015
Sent from the Papervision3D mailing list archive at Nabble.com.




More information about the Papervision3D mailing list