包 | flash.ui |
类 | public final class ContextMenuItem |
继承 | ContextMenuItem ![]() ![]() |
语言版本 : | ActionScript 3.0 |
Player 版本 : | Flash Player 9 |
customItems
数组。
利用 ContextMenuItem 类的属性,您可以启用或禁用特定菜单项,也可以显示或隐藏菜单项。
可以为menuItemSelect
事件编写事件处理程序,以便在用户选择菜单项时为其添加功能。
自定义菜单项出现在上下文菜单的顶部,并位于所有内置菜单项之上。 自定义菜单项与内置菜单项始终由分隔条隔开。
限制:
保存
放大
缩小
100%
全部显示
质量
播放
循环
后退
快进
快退
没有加载影片
关于
打印
显示重绘区域
调试器
撤消
剪切
复制
粘贴
删除
全选
打开
在新窗口中打开
复制链接
Adobe
Macromedia
Flash
Player
设置
注意:如果播放器运行在非英语系统上,标题字符串将同时与英语列表和对应的本地化字符串进行比较。
另请参见
属性 | 定义方 | ||
---|---|---|---|
caption : String
指定上下文菜单中显示的菜单项标题(文本)。
| ContextMenuItem | ||
![]() | constructor : Object
对类对象或给定对象实例的构造函数的引用。
| Object | |
enabled : Boolean
指示指定的菜单项处于启用状态还是禁用状态。
| ContextMenuItem | ||
![]() | prototype : Object
[static]
对类或函数对象的原型对象的引用。
| Object | |
separatorBefore : Boolean
指示指定的菜单项上方是否显示分隔条。
| ContextMenuItem | ||
visible : Boolean
指示在显示 Flash Player 上下文菜单时指定菜单项是否可见。
| ContextMenuItem |
方法 | 定义方 | ||
---|---|---|---|
ContextMenuItem(caption:String, separatorBefore:Boolean = false, enabled:Boolean = true, visible:Boolean = true)
创建一个可添加到 ContextMenu.customItems 数组的新 ContextMenuItem 对象。
| ContextMenuItem | ||
![]() |
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
使用 EventDispatcher 对象注册事件侦听器对象,以使侦听器能够接收事件通知。
| EventDispatcher | |
创建并返回指定的 ContextMenuItem 对象的副本。
| ContextMenuItem | ||
![]() |
将事件调度到事件流中。
| EventDispatcher | |
![]() |
检查 EventDispatcher 对象是否为特定事件类型注册了任何侦听器。
| EventDispatcher | |
![]() |
指示对象是否已经定义了指定的属性。
| Object | |
![]() |
指示 Object 类的实例是否在指定为参数的对象的原型链中。
| Object | |
![]() |
指示指定的属性是否存在、是否可枚举。
| Object | |
![]() |
从 EventDispatcher 对象中删除侦听器。
| EventDispatcher | |
![]() |
设置循环操作动态属性的可用性。
| Object | |
![]() |
返回指定对象的字符串表示形式。
| Object | |
![]() |
返回指定对象的原始值。
| Object | |
![]() |
检查是否用此 EventDispatcher 对象或其任何始祖为指定事件类型注册了事件侦听器。
| EventDispatcher |
事件 | 摘要 | 定义方 | ||
---|---|---|---|---|
![]() | Flash Player 获得操作系统焦点并变为活动状态时调度。 | EventDispatcher | ||
![]() | Flash Player 失去操作系统焦点并变为非活动状态时调度。 | EventDispatcher | ||
用户从上下文菜单中选择项时调度。 | ContextMenuItem |
caption | 属性 |
caption:String
[read-write]
语言版本 : | ActionScript 3.0 |
Player 版本 : | Flash Player 9 |
指定上下文菜单中显示的菜单项标题(文本)。 有关 caption
值限制,请参阅 ContextMenuItem 类概述。
public function get caption():String
public function set caption(value:String):void
enabled | 属性 |
enabled:Boolean
[read-write]
语言版本 : | ActionScript 3.0 |
Player 版本 : | Flash Player 9 |
指示指定的菜单项处于启用状态还是禁用状态。
默认值为 true
.
public function get enabled():Boolean
public function set enabled(value:Boolean):void
separatorBefore | 属性 |
separatorBefore:Boolean
[read-write]
语言版本 : | ActionScript 3.0 |
Player 版本 : | Flash Player 9 |
指示指定的菜单项上方是否显示分隔条。
注意:任何自定义菜单项和内置菜单项之间始终会出现分隔条。
默认值为 false
.
public function get separatorBefore():Boolean
public function set separatorBefore(value:Boolean):void
visible | 属性 |
visible:Boolean
[read-write]
语言版本 : | ActionScript 3.0 |
Player 版本 : | Flash Player 9 |
指示在显示 Flash Player 上下文菜单时指定菜单项是否可见。
默认值为 true
.
public function get visible():Boolean
public function set visible(value:Boolean):void
ContextMenuItem | () | 构造函数 |
public function ContextMenuItem(caption:String, separatorBefore:Boolean = false, enabled:Boolean = true, visible:Boolean = true)
语言版本 : | ActionScript 3.0 |
Player 版本 : | Flash Player 9 |
创建一个可添加到 ContextMenu.customItems
数组的新 ContextMenuItem 对象。
caption:String — 指定与菜单项关联的文本。 有关 caption 值限制,请参阅 ContextMenuItem 类概述。
|
|
separatorBefore:Boolean (default = false ) — 指定分隔条是否显示在上下文菜单中的菜单项上方。 默认值为 false 。
|
|
enabled:Boolean (default = true ) — 指定菜单项在上下文菜单中是处于启用状态还是禁用状态。 默认值为 true (启用)。 此参数是可选的。
|
|
visible:Boolean (default = true ) — 指定菜单项是否可见。 默认值为 true (可见)。
|
clone | () | 方法 |
public function clone():ContextMenuItem
语言版本 : | ActionScript 3.0 |
Player 版本 : | Flash Player 9 |
创建并返回指定的 ContextMenuItem 对象的副本。 该副本包含初始对象的所有属性。
返回ContextMenuItem — 包含原始对象的所有属性的 ContextMenuItem 对象。
|
menuItemSelect | 事件 |
flash.events.ContextMenuEvent
flash.events.ContextMenuEvent.MENU_ITEM_SELECT
语言版本 : | ActionScript 3.0 |
Player 版本 : | Flash Player 9 |
用户从上下文菜单中选择某一项时调度。 用户通过单击其指针设备的辅助按钮来生成上下文菜单。
定义menuItemSelect
事件对象的 type
属性值。
此事件具有以下属性:
属性 | 值 |
---|---|
bubbles | false |
cancelable | false ;没有要取消的默认行为。 |
contextMenuOwner | 菜单附加到的显示列表对象。 |
currentTarget | 当前正在使用某个事件侦听器处理 Event 对象的对象。 |
mouseTarget | 用户右键单击以显示上下文菜单的显示列表对象。 |
target | 已选定的 ContextMenuItem 对象。 target 不一定是显示列表中注册此事件侦听器的对象。 请使用 currentTarget 属性来访问显示列表中当前正在处理此事件的对象。 |
ContextMenuBuiltInItemsExample
类从舞台中删除默认的上下文菜单项,并添加新的菜单项。 这是由以下步骤完成的:
myContextMenu
,然后将其赋给新的 ContextMenu 对象。removeDefaultItems()
方法,该方法将删除所有内置的上下文菜单项(“打印”除外)。addCustomMenuItems()
方法,该方法使用数组的 push()
方法将称为 Hello World
的菜单项放入 customItems
数组。Hello World
上下文菜单项添加到舞台的上下文菜单项列表中。package { import flash.ui.ContextMenu; import flash.ui.ContextMenuItem; import flash.ui.ContextMenuBuiltInItems; import flash.display.Sprite; import flash.text.TextField; public class ContextMenuItemExample extends Sprite { private var myContextMenu:ContextMenu; public function ContextMenuItemExample() { myContextMenu = new ContextMenu(); removeDefaultItems(); addCustomMenuItems(); this.contextMenu = myContextMenu; addChild(createLabel()); } private function removeDefaultItems():void { myContextMenu.hideBuiltInItems(); var defaultItems:ContextMenuBuiltInItems = myContextMenu.builtInItems; defaultItems.print = true; } private function addCustomMenuItems():void { var item:ContextMenuItem = new ContextMenuItem("Hello World"); myContextMenu.customItems.push(item); } private function createLabel():TextField { var txtField:TextField = new TextField(); txtField.text = "Right Click Here"; return txtField; } } }
当前页: http://livedocs.adobe.com/flash/9.0_cn/ActionScriptLangRefV3/flash/ui/ContextMenuItem.html