MouseEvent3D not fired from clicking on a ObjectContainer3D or a Plane

Software: Away3D 4.x

Avatar
jansensan, Newbie
Posted: 05 January 2012 07:48 PM   Total Posts: 16

I am extending a ObjectContainer3D. Into that, I create a plane. That is all fine. Then I add event listeners onto an instance of that class, but they are never fired. Anything I should check for or know about?

CoverFlowItem class:

public class CoverFlowItem extends ObjectContainer3D implements IView
{
...
} 

In the parent class that contains instances of CoverFlowItem:

public function addItem(vo:CoverFlowThumbVO, update:Boolean = false):void
{
 
var item:CoverFlowItem = new CoverFlowItem();
 
item.setScale(_scale);
 
item.id = vo.id;
 
item.bitmapData = vo.bitmapData;
 
item.init();
 
item.addEventListener(MouseEvent3D.MOUSE_OVER, mouseEvent3DHandler);
 
item.addEventListener(MouseEvent3D.MOUSE_DOWN, mouseEvent3DHandler);
 
item.addEventListener(MouseEvent3D.MOUSE_UP, mouseEvent3DHandler);
 
item.addEventListener(MouseEvent3D.MOUSE_OUT, mouseEvent3DHandler);
 
item.addEventListener(MouseEvent3D.CLICK, mouseEvent3DHandler);
 
 
_items.push(item);
 
addChild(item);
 
 
_numItems = _items.length;
 
item.positionIndex = _numItems - 1;
 
 if(
update) updateItemsProperties(0);
}

private function mouseEvent3DHandler(event:MouseEvent3D):void
{
 trace
("n", this, "---  mouseEvent3DHandler  ---");
 
trace("t", "event: " + (event));
 
} 
   

Avatar
vonWolfehaus, Newbie
Posted: 05 January 2012 09:07 PM   Total Posts: 14   [ # 1 ]

I had this problem too and my solution was to set listeners on the child object (a plane in your case) that would call a method in the subclass.

It seems ObjectContainer3D just isn’t mouse-enabled, which needs to get fixed.

   

Avatar
jansensan, Newbie
Posted: 05 January 2012 09:24 PM   Total Posts: 16   [ # 2 ]

Thanks for your suggestion, however I had tried that as well, to no avail:

CoverFlowItem class:

public function init():void
{
 
var material:BitmapMaterial = new BitmapMaterial ( _bitmapData,
               
true, // smooth
               
false, // repeat
               
false // mipmap
              
);
 
material.bothSides = true;
 
 var 
plane:Plane = new Plane( material,
         
PLANE_WIDTH * _scale,
         
PLANE_HEIGHT * _scale
        
);
 
plane.addEventListener(MouseEvent3D.MOUSE_OVER, mouseEvent3DHandler);
 
plane.addEventListener(MouseEvent3D.MOUSE_OUT, mouseEvent3DHandler);
 
plane.addEventListener(MouseEvent3D.CLICK, mouseEvent3DHandler);
 
 
addChild(plane);
}

private function mouseEvent3DHandler(event:MouseEvent3D):void
{
 trace
("\n", this, "---  mouseEvent3DHandler  ---");
 
trace("\t", "event: " + (event));
} 
   

Avatar
vonWolfehaus, Newbie
Posted: 05 January 2012 09:50 PM   Total Posts: 14   [ # 3 ]

Looks like you might have forgotten to add “plane.mouseEnabled = true” in init(), before adding the listeners.

   

Avatar
jansensan, Newbie
Posted: 05 January 2012 09:56 PM   Total Posts: 16   [ # 4 ]

I just tested that, I was about to write exactly that here. It’s confusing, since it’s set to true by default in AS3 usual display objects. Thanks for the help!

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X