How can I pass data through a mouse event?

Software: Away3D 4.x

Avatar
martiniDave, Newbie
Posted: 17 September 2013 07:44 AM   Total Posts: 9

I need to collect data from a 3D object when a roll over event occurs(event.target.variable). I have tried adding a child object, storing the data in the name, even adding a public variable to either the mesh or object .as. All have been rejected. Can anyone give the appropriate method for this, it must be very common, I’ve just can’t find it in the docs. Thanks for any reply.

   

Avatar
SharpEdge, Member
Posted: 17 September 2013 07:59 AM   Total Posts: 94   [ # 1 ]

It’s simple, you should extend Mesh Class suppose we call it CustomMesh and add to it all your custom properties.

Then when you catch the event:

protected function onRollover(ev:MouseEvent3D):void
{
  
var myObj CustomMesh ev.object as CustomMesh;
  
trace(myObj.property1);
   

Avatar
mrpinc, Sr. Member
Posted: 17 September 2013 03:35 PM   Total Posts: 119   [ # 2 ]

Each Object3D has a property called ‘extra’  this is where you can store arbitrary data.

   

Avatar
SharpEdge, Member
Posted: 17 September 2013 03:52 PM   Total Posts: 94   [ # 3 ]

Ouch…I hadn’t noticed that feature!

   

Avatar
martiniDave, Newbie
Posted: 17 September 2013 06:54 PM   Total Posts: 9   [ # 4 ]

Thank you very much, the extra works perfect for me!

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X