MouseEvent3D and ownCanvas=true

29 views
Skip to first unread message

Alex Rico

unread,
Jan 13, 2010, 11:49:38 AM1/13/10
to Away3D.dev
Hi:

i'm having problems with the owncanvas property. When i try to add a
mouse3devent3d listener it doesn't work if the property owncanvas is
true.

this is my function:

private function windowMouseDown(e:MouseEvent3D):void
{
trace("click on window");
}

this code works:

var window:Plane = new Plane({material:windowMaterial, height:100,
width:100, segmentsH:4, segmentsW:4, ownCanvas:false});
window.bothsides=true;
window.screenZOffset=-1000;
view.scene.addChild(window);
window.addOnMouseDown(windowMouseDown);
// or window.addEventListener(MouseEvent3D.MOUSE_DOWN,
windowMouseDown);

this doesn't works:

var window:Plane = new Plane({material:windowMaterial, height:100,
width:100, segmentsH:4, segmentsW:4, ownCanvas:true}); //now i set
ownCanvas to true
window.bothsides=true;
window.screenZOffset=-1000;
view.scene.addChild(window);
window.addOnMouseDown(windowMouseDown);
// or window.addEventListener(MouseEvent3D.MOUSE_DOWN,
windowMouseDown);


I tried to add the object to and object container.

this code works:

windowContainer=new ObjectContainer3D();
view.scene.addChild(windowContainer);
var window:Plane = new Plane({material:windowMaterial, height:100,
width:100, segmentsH:4, segmentsW:4, ownCanvas:false});
window.bothsides=true;
window.screenZOffset=-1000;
windowContainer.addChild(window);
window.addOnMouseDown(windowMouseDown);
// or window.addEventListener(MouseEvent3D.MOUSE_DOWN,
windowMouseDown);

this doesn't works:

windowContainer=new ObjectContainer3D();
view.scene.addChild(windowContainer);
var window:Plane = new Plane({material:windowMaterial, height:100,
width:100, segmentsH:4, segmentsW:4, ownCanvas:true});//now i set
ownCanvas to true
window.bothsides=true;
window.screenZOffset=-1000;
windowContainer.addChild(window);
window.addOnMouseDown(windowMouseDown);
// or window.addEventListener(MouseEvent3D.MOUSE_DOWN,
windowMouseDown);

*in this case i can't add the event listener to the whole
objeccontainer3d because i have lots of planes (an array of planes). I
need to add the event listener to each plane.


What am i doing wrong? i need the onwcanvas property set to true, if i
can't add event listeners to the object while the property is false I
have a big problem.

Thank You.

Alex.

Rob Bateman

unread,
Feb 2, 2010, 5:35:54 PM2/2/10
to away3...@googlegroups.com
Hey Alex

this will most likely be because you are using screenZOffset, which is only active when you use ownCanvas = true;

screenZOffset affects the order items are rendered, but it will also affect mouse events as anything with a screenZ coord less than that will obstruct 3d mouse events

i would try removing the screenZOffset from your example to see if you still have the problem

atb

Rob
--
Rob Bateman
Flash Development & Consultancy

rob.b...@gmail.com
www.infiniteturtles.co.uk
www.away3d.com
Reply all
Reply to author
Forward
0 new messages