<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" width="519" height="446" creationComplete="init()" backgroundColor="#0B0B0B">
<fx:Script>
<![CDATA[
//导入这些东西比较重要,我们主要靠这些混饭吃
import flash.display.Sprite;
import flash.ui.ContextMenu;
import flash.ui.ContextMenuItem;
import flash.events.ContextMenuEvent;
private var menu1:ContextMenuItem;
//初始化开始了
public function init():void{
menu1= new ContextMenuItem("Version:3.110601");//背景菜单项
menu1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,menudraw);//监听菜单事件
//menu1.enabled=false;//灰色按钮
//菜单、事件全部加到一起,放在ContextMenu上
var MyMenu:ContextMenu = new ContextMenu();
MyMenu.hideBuiltInItems();//隐藏菜单
MyMenu.customItems.push(menu1);
this.contextMenu = MyMenu;//这个是整个舞台的监听.
}
//选择选择到了右键栏目,改干点啥
private function menudraw(e:ContextMenuEvent):void {
switch (e.target) {
case menu1 :
textSelect.text = "你选中了版本菜单Version:3.110601";
break;
}
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" width="519" height="446" creationComplete="init()" backgroundColor="#0B0B0B">
<fx:Script>
<![CDATA[
//导入这些东西比较重要,我们主要靠这些混饭吃
import flash.display.Sprite;
import flash.ui.ContextMenu;
import flash.ui.ContextMenuItem;
import flash.events.ContextMenuEvent;
private var menu1:ContextMenuItem;
//初始化开始了
public function init():void{
menu1= new ContextMenuItem("Version:3.110601");//背景菜单项
menu1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,menudraw);//监听菜单事件
//menu1.enabled=false;//灰色按钮
//菜单、事件全部加到一起,放在ContextMenu上
var MyMenu:ContextMenu = new ContextMenu();
MyMenu.hideBuiltInItems();//隐藏菜单
MyMenu.customItems.push(menu1);
this.contextMenu = MyMenu;//这个是整个舞台的监听.
}
//选择选择到了右键栏目,改干点啥
private function menudraw(e:ContextMenuEvent):void {
switch (e.target) {
case menu1 :
textSelect.text = "你选中了版本菜单Version:3.110601";
break;
}
}
]]></fx:Script><s:Label x="97" y="60" id="textSelect" text="在这里是内容测试哦" fontSize="20" color="#BB0404" fontWeight="normal"/><fx:Declarations><!-- 将非可视元素(例如服务、值对象)放在此处 --></fx:Declarations></s:Application>