• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1682
  • Last Modified:

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
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);
}

Open in new window

0
Dreammonkey
Asked:
Dreammonkey
  • 4
  • 3
1 Solution
 
pepsichrisCommented:
It's basically cos CLICK doesn't bubble in the same way a MOUSE_OVER/ROLL_OVER etc, and Papervision sets the scenario up slightly differently to how you expect, so you need to work around it.  There's a nice tutorial here:

http://papervision2.com/advanced-interactivity-2/

...which will show you the basis for the cleanest workaround.  Good luck!
0
 
DreammonkeyAuthor Commented:
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).
http://www.experts-exchange.com/Software/Photos_Graphics/Web_Graphics/Macromedia_Flash/ActionScript/Q_24122261.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!!!");
	}
}

Open in new window

0
 
pepsichrisCommented:
Out of interest, have you even tried replacing MouseEvent.CLICK with InteractiveScene3DEvent.OBJECT_CLICK
?

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
DreammonkeyAuthor Commented:
well, I was just about to... ;)
0
 
DreammonkeyAuthor Commented:
bloody marvellous !


cube.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, onTileClick);
function onTileClick(e:InteractiveScene3DEvent) {
	var lookFor:*=scene.getChildAt(e.currentTarget.inc);
	trace( lookFor.name+" was CLICKED!!!");
}

Open in new window

0
 
pepsichrisCommented:
Glad it worked out!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now