|
ytr2345, Newbie
Posted: 12 September 2013 10:55 AM Total Posts: 22
Hi, how to change away3d link in the right click menu ?
|
ytr2345, Newbie
Posted: 13 September 2013 09:47 AM Total Posts: 22
[ # 1 ]
Anyone know about this ?
|
SharpEdge, Member
Posted: 13 September 2013 10:04 AM Total Posts: 94
[ # 2 ]
you should look for “ContextMenu” Class of AS3.
The away3d link is setted inside View3D so if you want to disable it just set “view.rightClickMenuEnabled = false;”
If you want to change it you should search Google for ContextMenu as i said.
|
ytr2345, Newbie
Posted: 15 September 2013 11:58 AM Total Posts: 22
[ # 3 ]
Thanks for the word, i find lots of topic.
When i try these code alone, it work, but when i embed it with away3d, nothing happened. This is my code,can you find where the error or away3d can not change the link in context menu.
package { import away3d.containers.*; import away3d.entities.*; import away3d.materials.*; import away3d.primitives.*; import away3d.utils.*; import flash.display.*; import flash.events.*; import flash.geom.Vector3D;
import flash.utils.*;
[SWF(backgroundColor="#000000", frameRate="60", quality="LOW")] public class Basic_View extends Sprite { [Embed(source="/../embeds/floor_diffuse.jpg")] public static var FloorDiffuse:Class;
private var _view:View3D; private var _plane:Mesh; public function Basic_View() { var my_menu:ContextMenu = new ContextMenu(); my_menu.hideBuiltInItems(); var my_notice = new ContextMenuItem("Test"); var my_email = new ContextMenuItem("123@gmail.com"); var my_copyright = new ContextMenuItem("Copyright"); my_copyright.enabled = false; my_copyright.separatorBefore = true; function openLink(e:ContextMenuEvent):void{ navigateToURL(new URLRequest("http://www.google.com")); } my_notice.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, openLink); my_menu.customItems.push(my_notice, my_email, my_copyright) ; contextMenu = my_menu; } private function init(e:Event = null):void { stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; _view = new View3D(); addChild(_view); _view.camera.z = -600; _view.camera.y = 500; _view.camera.lookAt(new Vector3D()); _plane = new Mesh(new PlaneGeometry(700, 700), new TextureMaterial(Cast.bitmapTexture(FloorDiffuse))); _view.scene.addChild(_plane); addEventListener(Event.ENTER_FRAME, _onEnterFrame); stage.addEventListener(Event.RESIZE, onResize); onResize(); } private function _onEnterFrame(e:Event):void { _plane.rotationY += 1; _view.render(); } private function onResize(event:Event = null):void { _view.width = stage.stageWidth; _view.height = stage.stageHeight; } } }
|
SharpEdge, Member
Posted: 15 September 2013 12:25 PM Total Posts: 94
[ # 4 ]
I told you…you have to set view.rightclickmenuenabled to false before setting your own menu.
|
ytr2345, Newbie
Posted: 15 September 2013 04:06 PM Total Posts: 22
[ # 5 ]
thanks, i set it with these code but nothing happen expect it lose the away3d in context menu, this is my code, can you write it for me, the custom context menu code i take in here: http://www.republicofcode.com/tutorials/flash/as3contextmenu/
this is my code:
package { import away3d.containers.*; import away3d.entities.*; import away3d.materials.*; import away3d.primitives.*; import away3d.utils.*; import flash.display.*; import flash.events.*; import flash.geom.Vector3D;
import flash.utils.*;
[SWF(backgroundColor="#000000", frameRate="60", quality="LOW")] public class Basic_View extends Sprite { [Embed(source="/../embeds/floor_diffuse.jpg")] public static var FloorDiffuse:Class; private var _view:View3D; private var _plane:Mesh; public function Basic_View() { if (stage) setTimeout(init, 0); else addEventListener(Event.ADDED_TO_STAGE, init); } private function init(e:Event = null):void { stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; _view = new View3D(); addChild(_view); _view.camera.z = -600; _view.camera.y = 500; _view.camera.lookAt(new Vector3D()); _plane = new Mesh(new PlaneGeometry(700, 700), new TextureMaterial(Cast.bitmapTexture(FloorDiffuse))); _view.scene.addChild(_plane); addEventListener(Event.ENTER_FRAME, _onEnterFrame); stage.addEventListener(Event.RESIZE, onResize); onResize(); } private function _onEnterFrame(e:Event):void { _plane.rotationY += 1; _view.render(); } private function onResize(event:Event = null):void { _view.width = stage.stageWidth; _view.height = stage.stageHeight; } } }
|
SharpEdge, Member
Posted: 16 September 2013 07:43 AM Total Posts: 94
[ # 6 ]
This is how View3D handles it:
private function initRightClickMenu():void { _menu0 = new ContextMenuItem("Away3D.com\tv" + Away3D.MAJOR_VERSION + "." + Away3D.MINOR_VERSION + "." + Away3D.REVISION, true, true, true); _menu1 = new ContextMenuItem("View Source", true, true, true); _menu0.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, visitWebsite); _menu1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, viewSource); _ViewContextMenu = new ContextMenu(); updateRightClickMenu(); } private function updateRightClickMenu():void { if (_rightClickMenuEnabled) _ViewContextMenu.customItems = _sourceURL? [_menu0, _menu1] : [_menu0]; else _ViewContextMenu.customItems = []; contextMenu = _ViewContextMenu; }
I think it’s quite clear.
|
SharpEdge, Member
Posted: 16 September 2013 07:43 AM Total Posts: 94
[ # 7 ]
|
ytr2345, Newbie
Posted: 16 September 2013 10:27 AM Total Posts: 22
[ # 8 ]
Thanks, i did it, you are my hero
|
SharpEdge, Member
Posted: 16 September 2013 10:32 AM Total Posts: 94
[ # 9 ]
Glad to help
|
joyful, Newbie
Posted: 17 December 2013 01:24 PM Total Posts: 2
[ # 10 ]
n2g6t1q1 - 16 September 2013 10:27 AM Thanks, i did it, you are my hero
|
joyful, Newbie
Posted: 17 December 2013 01:27 PM Total Posts: 2
[ # 11 ]
Hi, n2g6t1q1! Can you share you work code, when you change right click menu? Now I only change main file View3D.as But how I can do this without change in View3D.as in my own class.
|
SharpEdge, Member
Posted: 18 December 2013 07:26 AM Total Posts: 94
[ # 12 ]
No no no you don’t have to edit View3D.as never!
As i said to n2g6t1q1! you should first disable the view3d menu and than create your own using the same code of view3d.as but in your class.
i posted that code just as reference but you must not change it!
|