Objects do not recognize events

Software: Away3D 4.x

Lucid, Member
Posted: 22 March 2012 12:19 PM   Total Posts: 93

This does not work:

var sphere:SphereGeometry = new SphereGeometry(1024,32,32);
mesh = new Mesh( sphere );
mesh.addEventListener(“mouseDown”,function(){trace(‘down’)})

Why?

   

Vice, Member
Posted: 22 March 2012 12:27 PM   Total Posts: 58   [ # 1 ]

you have to use MouseEvent3D

e. g.: addEventListener(MouseEvent3D.MOUSE_UP, yourFunction);

   

Lucid, Member
Posted: 22 March 2012 12:40 PM   Total Posts: 93   [ # 2 ]

Yes, this works but how was I supposed to find this? The mesh class doesn’t even show this as an option when adding an event listener.

I know Away3D 4 is still in beta but damn. C’mon folks! That seems like a pretty essential, rudimentary feature no? Seems like the majority of questions on the forum are just about doing rudimentary things (like adding a mouse down event on an object).

   

Vice, Member
Posted: 22 March 2012 01:36 PM   Total Posts: 58   [ # 3 ]

it works fine! just use the eventListener and dont forget to import away3d.events.MouseEvent3D

   

John Brookes, Moderator
Posted: 22 March 2012 01:49 PM   Total Posts: 732   [ # 4 ]

The issue has been on the git for a while
https://github.com/away3d/away3d-core-fp11/issues/174

Click that above follow link back to the forum and change objectContainer3d.as

Then you will get nice code completion smile

And yeah its annoying, been using away for ages and can never remember whether is mouse3devent or mouseevent3d. Always choose the wrong one smile

   

charlito, Jr. Member
Posted: 22 March 2012 11:37 PM   Total Posts: 36   [ # 5 ]

hi

i had the same problem..

here is an example of working code to add an event to a mesh

public class away3D_mouseEvent extends Sprite
 {
  
  
public var view:View3D = new View3D();
  
  public var 
plano:PlaneGeometry = new PlaneGeometry(500,500,1,1,false);
  public var 
plano_mat:ColorMaterial = new ColorMaterial(0x000fff);
  public var 
malla:Mesh;
  
  
[Event(name "click3d"type "away3d.events.MouseEvent3D")
  

  
public function away3D_mouseEvent()
  
{
      
   view
.backgroundColor 0xB0C4DE;
   
addChild(view);
   
malla= new Mesh(plano,plano_mat);
   
   
malla.mouseEnabled true;
   
      
view.scene.addChild(malla);

   
malla.addEventListener(MouseEvent3D.CLICK,prueba);
   
   
this.addEventListener(Event.ENTER_FRAMEloop);
  
}
  
     
public function prueba(e:Event):void
  {
   trace
("has clickeado  :)");
  
}
  
  
public function loop(e:Event):void
  {
   
   view
.render();
  
}
  
  
  
 } 

so everyone else who has this problem, have a simple solution

grettings..

 

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X