I have been playing around with Lee's tutorial for papervision - very cool!!
Have got it zooming in and out with the mouse wheel and alpha.
But not having much luck with a button press/click.
I can get a click to register but because I think I am out of scope of the loop it only registers the last object. I can get a trace to tell me the number of each object but cannot target it.
- Code: Select all
import flash.system.fscommand;
fscommand("fullscreen", "true");
fscommand("allowscale", "false");
import org.papervision3d.scenes.*;
import org.papervision3d.cameras.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.*;
var container:Sprite = new Sprite();
container.x = stage.stageWidth * 0.5;
container.y = stage.stageHeight * 0.5;
container.scaleX = container.scaleY = 2;
addChild(container);
trace(container.scaleX);
var scene:Scene3D = new Scene3D(container);
var camera:Camera3D = new Camera3D();
camera.zoom = 2;
var bam:BitmapAssetMaterial = new BitmapAssetMaterial("surf");
bam.oneSide = false;
bam.smooth = true;
for(var i:uint; i < 50; i++){
var p:Plane = new Plane(bam, 100, 100, 2, 2);
scene.addChild(p);
p.x = Math.random() * 600 - 350;
p.y = Math.random() * 600 - 350;
p.z = Math.random() * 600 - 350;
p.rotationY = Math.random() * 360;
["null"+i]addEventListener(MouseEvent.CLICK, clicked);
trace(["null"+i])
}
function clicked (event:MouseEvent):void {
trace("clicked= "+["null"+i]);//"this" without the quotes does not work
}
this.addEventListener(Event.ENTER_FRAME, render);
function render(e:Event):void{
camera.x = stage.mouseX - (stage.stageWidth * .5);
camera.y = stage.mouseY - (stage.stageHeight * .5);
camera.z = stage.mouseY - (stage.stageHeight * .05);
//trace(container.scaleX);
scene.renderCamera(camera);
}
Maybe I have to wrap it in another movie clip/sprite but I am not sure how to.
Any ideas?
Have uploaded the swf if you would like to see the zoom. (zip as it is quite large)
easy
