MouseEvent3D not fireing

Software: Away3D 4.x

ActionFrob, Newbie
Posted: 28 November 2012 09:36 AM   Total Posts: 10

Hi @all!

I’m new to Away3D and i’ve a problem concerning the MouseEvent3D. I’ve no idea why the event is not fired. Can you please help me?
The application is a simple cube, where an eventlistener is registered. When I click on the cube, nothing happens. Not even the listener is executed.
What you see below are my methods in the main class which extends the flash.display.Sprite class.

private function onAddedStage():void
{

  
// Setup scene
  
_scene = new Scene3D();
   
 
// Setup camera
 
_camera = new Camera3D();

   
 
// Setup view
 
_view = new View3D();
   

 
_view.mousePicker PickingType.SHADER;
 
_view.antiAlias 16;
 
_scene _view.scene;
 
_camera _view.camera;
  
   

 
_view.backgroundColor 0xffffff;
 
_view.width 742;
 
_view.height 274;
 
addChild(_view);
   
   
 
_camController = new HoverController(_cameranull360,0);
 
_directionalLight = new DirectionalLight();
 
_directionalLight.lookAt( new Vector3D());
 
_directionalLight.diffuse 1.0;
 
_directionalLight.specular 1.0;
 
_scene.addChild(_directionalLight);
   
 
_pointLight = new PointLight();
 
_pointLight.color 0xffffff;
 
_pointLight.400;
 
_pointLight.specular =  0.4;
 
_pointLight.diffuse 1.0;
 
_scene.addChild(_pointLight); 

   
 
_simpleMaterial = new ColorMaterial(0xFF0000);
 
_lightPicker = new StaticLightPicker([_directionalLight,_pointLight]);
 
_simpleMaterial.lightPicker _lightPicker;
   
   
 
_cube = new Mesh(new CubeGeometry(400,400,400),_simpleMaterial);
 
_cube.mouseEnabled true;
 
_cube.pickingCollider PickingColliderType.BOUNDS_ONLY;
 
_cube.addEventListener(MouseEvent3D.CLICKonMouseDown);
 
_scene.addChild(_cube);

 
addEventListener(Event.ENTER_FRAMEonEnterFrame);
}
private function onEnterFrame(event:Event):void
{
 _cube
.rotationY += .5;
 
_view.render();
   
}
  
private function onMouseDown(event:MouseEvent3D):void{
 trace
(event.type);
   
   

Avatar
loth, Sr. Member
Posted: 28 November 2012 09:55 AM   Total Posts: 236   [ # 1 ]

add this
_view.forceMouseMove = true;

   

ActionFrob, Newbie
Posted: 28 November 2012 10:13 AM   Total Posts: 10   [ # 2 ]

Thanks for reply but this didn’t solved it. Now I’ve:

private function onAddedStage():void
  {

   
// Setup scene
   
_scene = new Scene3D();
   
   
// Setup camera
   
_camera = new Camera3D();

   
   
// Setup view
   
_view = new View3D();
   
_view.forceMouseMove true;
   
_view.mousePicker PickingType.SHADER;
   
_view.antiAlias 16;
   
_scene _view.scene;
   
_camera _view.camera;
  

   
_view.backgroundColor 0xffffff;
   
_view.width 742;
   
_view.height 274;
   
addChild(_view);
   
   
   
   
_camController = new HoverController(_cameranull360,0);
   
   
_directionalLight = new DirectionalLight();

   
_directionalLight.lookAt( new Vector3D());
   
_directionalLight.diffuse 1.0;
   
_directionalLight.specular 1.0;
   
_scene.addChild(_directionalLight);
   
   
_pointLight = new PointLight();
   
_pointLight.color 0xffffff;
   
_pointLight.400;
   
_pointLight.specular =  0.4;
   
_pointLight.diffuse 1.0;
   
_scene.addChild(_pointLight); 

   
   
_simpleMaterial = new ColorMaterial(0xFF0000);
   
_lightPicker = new StaticLightPicker([_directionalLight,_pointLight]);
   
_simpleMaterial.lightPicker _lightPicker;

   
   
_cube = new Mesh(new CubeGeometry(400,400,400),_simpleMaterial);
   
_cube.mouseEnabled true;
   
_cube.shaderPickingDetails true;
   
_cube.pickingCollider  =PickingColliderType.PB_FIRST_ENCOUNTERED;
   
//_cube.pickingCollider = PickingColliderType.BOUNDS_ONLY;
   
_cube.addEventListener(MouseEvent3D.CLICKonMouseDown);
   
_scene.addChild(_cube);


   
addEventListener(Event.ENTER_FRAMEonEnterFrame);
  
}
  
private function onEnterFrame(event:Event):void
  {
   _cube
.rotationY += .5;
   
_view.render();
   
  
}
  
  
private function onMouseDown(event:MouseEvent3D):void{
   trace
(event.type);

   
  
   

Avatar
Alejandro Santander, Administrator
Posted: 28 November 2012 05:12 PM   Total Posts: 414   [ # 3 ]

Hey,

Thanks for reporting this bug. Please give me a couple of days to study it. I will also see why the link you posted is not visible.

I will report any progress on this thread.

   

ActionFrob, Newbie
Posted: 28 November 2012 09:22 PM   Total Posts: 10   [ # 4 ]

FYI: I tried a few things and the following code works for me. I don’t know what exactly the difference is to my previous code. If it’s a bug, it’s ok to me wink
Thanks again for your fast reply on this.

private function onAddedStage():void
  {
   
   stage
.scaleMode StageScaleMode.NO_SCALE;
   
stage.align StageAlign.TOP_LEFT;
   
stage.frameRate 60;

   
   
_view = new View3D();
   
_view.camera.lens.far 15000;

   
_view.forceMouseMove true;
   
_view.mouseEnabled true;
   

   
_view.antiAlias 16;
   
_view.backgroundColor 0xffffff;
   
_view.width 742;
   
_view.height 274;
   
addChild(_view);

   
_camController = new HoverController(_view.cameranull00, -300 );

   
_directionalLight = new DirectionalLight();
   
_directionalLight.lookAt( new Vector3D());
   
_directionalLight.diffuse 1.0;
   
_directionalLight.specular 1.0;

   
_pointLight = new PointLight();

   
_lightPicker = new StaticLightPicker([_pointLight]);

   
_view.scene.addChild(_pointLight);

   
   
_simpleMaterial = new ColorMaterial(0xFF0000);
   
_simpleMaterial.lightPicker _lightPicker;
   
_simpleMaterial2 = new ColorMaterial(0x0000FF);
   
_simpleMaterial2.lightPicker _lightPicker;  
   
_simpleMaterial3 = new ColorMaterial(0x00FF00);
   
_simpleMaterial3.lightPicker _lightPicker;

   
_cube = new Mesh(new CubeGeometry(80,80,80,1,1,1),_simpleMaterial);
   
_cube.= -80;
   
_cube.rotationY +=50;
   
_view.scene.addChild(_cube);
   
_cube.mouseEnabled true;
   
_cube.addEventListener(MouseEvent3D.MOUSE_OVERonMouseOver);
   
_cube.addEventListener(MouseEvent3D.MOUSE_OUTonMouseOut);
   
_cube.addEventListener(MouseEvent3D.DOUBLE_CLICKonMouseDbClick);
   
_cube.addEventListener(MouseEvent3D.MOUSE_DOWNonMouseDown);
   
_cube.addEventListener(MouseEvent3D.MOUSE_UPonMouseUp); 
   
   
_cube2 = new Mesh(new CubeGeometry(150,150,150),_simpleMaterial3);
   
_cube2.100;   
   
_view.scene.addChild(_cube2);

   
_drag3d = new Drag3D(_viewObjectContainer3D(_cube));
   
_drag3d.plane Drag3D.PLANE_XY;
   
_drag3d.offsetCenter true;
   
addEventListener(Event.ENTER_FRAMEonEnterFrame);
  
}
  
private function onEnterFrame(event:Event):void
  {
   
   
if(_mouseIsDown3D)
   
   
{

    _cube
.mouseEnabled false;
    
_drag3d.updateDrag();
    
trace(_cube.x);
    
_cube.mouseEnabled true;
   
}

   
if(_rotation)
    
   
{
    _cube
.rotationY +=1;
   
}else{
    _cube
.rotationY 90;
   
}
   _pointLight
.position _view.camera.position;
   
_view.render();
   
  
}
  
  
private function onMouseOver(event:MouseEvent3D):void{
    
   
var cube:Mesh event.target as Mesh;
   
cube.material _simpleMaterial2;

   
  
}
  
  
private function onMouseOut(event:MouseEvent3D):void{
   
   
var cube:Mesh event.target as Mesh;
   
cube.material _simpleMaterial;
   
  
}
  
private function onMouseDbClick(event:MouseEvent3D):void{
   _rotation 
= !_rotation;
   
  
}
  
  
private function onMouseDown(event:MouseEvent3D):void{
   _mouseIsDown3D 
= !_mouseIsDown3D;
   
  
}
  
private function onMouseUp(event:MouseEvent3D):void{
   _mouseIsDown3D 
= !_mouseIsDown3D;
   
  
   

Avatar
Alejandro Santander, Administrator
Posted: 01 December 2012 10:20 PM   Total Posts: 414   [ # 5 ]

Ok, I managed to have a look. I don’t know exactly what’s going on with AIR Mobile or AIR Mobile + Away3D regarding the MouseEvent3D.MOUSE_DOWN event, but it seems to not be triggered correctly. I recommend using MouseEvent3D.MOUSE_UP or MouseEvent3D.CLICK for now while the problem is studied in greater detail.

   

Avatar
Alejandro Santander, Administrator
Posted: 01 December 2012 11:07 PM   Total Posts: 414   [ # 6 ]

I’ve suggested a fix in the hotfix branch. You can use mouse down events on tablets with this. If it get’s aprooval it should make it to the master branch soon.

Cheers for picking this up!

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X