Gestione degli eventi

import flash.display.Sprite;
import flash.events.Event;
	
import org.papervision3d.view.Viewport3D;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.materials.*;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.primitives.*;
import org.papervision3d.render.BasicRenderEngine;
import org.papervision3d.events.InteractiveScene3DEvent;
import org.papervision3d.core.proto.MaterialObject3D;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.materials.shadematerials.*;
import caurina.transitions.Tweener;

var viewport:		Viewport3D;
var scena:			Scene3D;
var camera:			Camera3D;
var materiale:		ColorMaterial;
var renderer:		BasicRenderEngine;
var solido:			Sphere;
var luce:			PointLight3D;
	
viewport = new Viewport3D(550, 400, false, true);
addChild(viewport);
scena = new Scene3D();
camera = new Camera3D();
camera.z=-400;
camera.rotationY=15;
renderer = new BasicRenderEngine();

//creiamo la nostra scena
luce = new PointLight3D(true);
luce.x = -300;
luce.y = 500;
luce.z = -200;
var flatShadedMaterial:MaterialObject3D = new FlatShadeMaterial(luce, 0xFF5555, 0x550000);
flatShadedMaterial.interactive = true;
solido = new Sphere(flatShadedMaterial, 50, 10, 10);
solido.y=-100;
scena.addChild(solido);

// aggiungiamo l'interattivitą
solido.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, doJump);
function doJump(event:InteractiveScene3DEvent) {
	event.displayObject3D.rotationX=0;
	var movZ =event.displayObject3D.z+100;
	Tweener.addTween(event.displayObject3D, {
		y:150, z:movZ, rotationX:90, time:0.5, transition:"easeOutSine",  
		onComplete:function():void {
			downJump(event.displayObject3D);
		}
 	}
	);
}

function downJump(obj):void {
	Tweener.addTween(obj, {
		y:-100,
		time:1, transition:"easeOutBounce"}
	);
	var movZ =obj.z+200;
	Tweener.addTween(obj, {
		z:movZ,
		rotationX:360,
		time:1, transition:"easeInOutSine"}
	);

}

addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame(e:Event):void {
	renderer.renderScene(scena, camera, viewport);
}