Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Following code is working. I have created a 300x300 shape and assigned context menu on it. The mouse position will be displayed in the text box in top-left corner.</p> <pre><code>package { import flash.ui.ContextMenuItem; import flash.display.MovieClip; import flash.events.MouseEvent; import flash.text.TextFormat; import flash.display.Sprite; import flash.text.TextField; import flash.ui.ContextMenu; import flash.display.Shape; /** * ... * @author GR */ public class Main extends Sprite { private var cm_item1:ContextMenuItem = new ContextMenuItem("Menu Item 1"); private var cm_item2:ContextMenuItem = new ContextMenuItem("Menu Item 2"); private var cm_item3:ContextMenuItem = new ContextMenuItem("Menu Item 3"); private var cm_item4:ContextMenuItem = new ContextMenuItem("Menu Item 4"); private var txtFormat:TextFormat = new TextFormat("Arial", 20, 0x000000); private var c_menu:ContextMenu = new ContextMenu(); private var map_mc:MovieClip = new MovieClip(); private var txt:TextField = new TextField(); private var bg:Shape = new Shape(); public function Main():void { bg.graphics.beginFill(0x00ffff); bg.graphics.drawRect(0, 0, 300, 300); bg.graphics.endFill(); map_mc.addChild(bg); map_mc.x = map_mc.y = 100; addChild(map_mc); txt.background = 0xffffff; txt.border = true; txt.defaultTextFormat = txtFormat; txt.width = 200; addChild(txt); c_menu.hideBuiltInItems(); c_menu.customItems.push(cm_item1, cm_item2, cm_item3, cm_item4); map_mc.contextMenu = c_menu; map_mc.addEventListener(MouseEvent.CONTEXT_MENU, cmFx); } private function cmFx(e:MouseEvent):void { txt.text = "x: " + mouseX + " y: " + mouseY; } } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload