Dreammonkey
asked on
papervision3d unable to use MouseEvents.CLICK ; MOUSE_DOWN & MOUSE_UP
I'm using code below to listen for mouseEvents on Planes in my papervision3d (v 2.0) scene.
The MOUSE_OVER and MOUSE_OUT Listeners seem to work;
The CLICK ; MOUSE_UP; MOUSE_DOWN don't work !
why could this be?
Thanks in advance,
DM
The MOUSE_OVER and MOUSE_OUT Listeners seem to work;
The CLICK ; MOUSE_UP; MOUSE_DOWN don't work !
why could this be?
Thanks in advance,
DM
var viewport:Viewport3D = new Viewport3D(0, 0, true, true);
addChild(viewport);
var renderer:BasicRenderEngine = new BasicRenderEngine();
var scene:Scene3D = new Scene3D();
var camera:Camera3D = new Camera3D();
camera.zoom = 11;
camera.focus = 50;
var terSize:uint=2;
var kwad:uint=terSize*terSize;
var row:uint=1;
var mam:MovieMaterial;
var cube:Plane;
var tile:earth;
var terArray:Array = new Array();
for (var i:uint=0; i<kwad; i++) {
if (i==terSize*row) {
row++;
}
terArray.push(new earth());
tile = terArray[i];
mam = new MovieMaterial(tile);
mam.interactive = true;
mam.smooth = true;
mam.animated = true;
cube = new Plane(mam);
cube.name = "Tile "+i.toString();
cube.x = (i-(terSize*(row-1)))*200;
cube.y = 200*(row-1);
//THIS ONE WORKS
cube.addEventListener(MouseEvent.MOUSE_OVER, onTileOver);
function onTileOver(e:Event):void {
trace(e.currentTarget.name);
}
//THIS ONE DOESN'T ...
cube.addEventListener(MouseEvent.CLICK, onTileClick);
function onTileClick(e:Event):void {
trace(e.currentTarget.name);
}
scene.addChild(cube);
}
ASKER
Thanks for the tip !
Good to see there actually are tutorials on papervision out there !
The approach is a bit far fetched for me, I tried it but it's very heavy on the cpu ...
and not that reliable after all...
What's more I'm working with planes (a lot of them) what makes it even more complex...
I tried another backdoor (see snippet)
Any idea if one could extend the papervison3d class to enable these listeners after all?
I don't see why the mouse_over and mouse_out are supported and the others aren't...
PS: In my previous question we found that it wasn't a big deal to extend the class so it would allow the getChildAt method (not supported in papervision either).
https://www.experts-exchange.com/questions/24122261/Papervision3d-Scene3D-getChildAt-method-undefined.html
Good to see there actually are tutorials on papervision out there !
The approach is a bit far fetched for me, I tried it but it's very heavy on the cpu ...
and not that reliable after all...
What's more I'm working with planes (a lot of them) what makes it even more complex...
I tried another backdoor (see snippet)
Any idea if one could extend the papervison3d class to enable these listeners after all?
I don't see why the mouse_over and mouse_out are supported and the others aren't...
PS: In my previous question we found that it wasn't a big deal to extend the class so it would allow the getChildAt method (not supported in papervision either).
https://www.experts-exchange.com/questions/24122261/Papervision3d-Scene3D-getChildAt-method-undefined.html
cube.addEventListener(MouseEvent.MOUSE_OVER, onTileOver);
cube.addEventListener(MouseEvent.MOUSE_OUT, onTileOut);
function onTileOver(e:Event):void {
//trace(e.currentTarget.name);
lookFor =scene.getChildAt(e.currentTarget.inc);
trace(lookFor.inc);
}
function onTileOut(e:Event):void {
//trace(e.currentTarget.name);
lookFor =null;
trace(lookFor);
}
holder.Tholder.addEventListener( MouseEvent.CLICK, onTileClick);
function onTileClick(e:MouseEvent) {
if(lookFor != null) {
trace( lookFor.name+" was CLICKED!!!");
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
well, I was just about to... ;)
ASKER
bloody marvellous !
cube.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, onTileClick);
function onTileClick(e:InteractiveScene3DEvent) {
var lookFor:*=scene.getChildAt(e.currentTarget.inc);
trace( lookFor.name+" was CLICKED!!!");
}
Glad it worked out!
http://papervision2.com/advanced-interactivity-2/
...which will show you the basis for the cleanest workaround. Good luck!