Context menu over an object

Software: Away3D 4.x

owsky, Newbie
Posted: 18 December 2013 04:31 PM   Total Posts: 2

Hey guys, first ask your pardon for my English.

I am trying to create a context menu that is displayed when I press the right mouse button on an object, such as a cube.

I’ve gone mad and I have looked a thousand examples but I can not give any man that does this.

var rootMenu:NativeMenu = new NativeMenu;
var 
submenu:NativeMenuItem rootMenu.addItem(new NativeMenuItem("File"));
_view.contextMenu rootMenu

Please, if someone could give me an example i thank it very much.

Thank you.

regards

   

Avatar
Mu Duck, Newbie
Posted: 18 December 2013 05:01 PM   Total Posts: 20   [ # 1 ]

You need to follow this guide: http://away3d.com/tutorials/Introduction_to_Mouse_Picking

For your case you need to get PickingCollisionVO object. Access its localPosition property. Than use project() method of your view3D object to translate that point to 2D-coordinates.

   

owsky, Newbie
Posted: 18 December 2013 05:31 PM   Total Posts: 2   [ # 2 ]

Thanks Duck,

is very useful the information you provided. Just one more thing, once I have the 2D point, what would be the code to display menu? My knowledge is a bit limited.

Thank you.

regards

   

Avatar
Mu Duck, Newbie
Posted: 18 December 2013 06:35 PM   Total Posts: 20   [ # 3 ]

I don’t know the NativeMenu class, but it should have probably x and y properties like Sprite. The project method will return you Vector3D with x and y properties as well. So you will just assign x and y from Vector3D to x and y of NativeMenu.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X