Adobe® Flash® Platform 用 ActionScript® 3.0 リファレンスガイド
ホーム  |  パッケージおよびクラスリストの非表示 |  パッケージ  |  クラス  |  新機能  |  索引  |  付録  |  英語で表示される理由
フィルター: AIR 30.0 以前, Flash Player 30.0 以前, Flash Lite 4
Flex 4.6 以前, Flash Pro CS6 以前
フィルターを非表示
flash.events 

ContextMenuEvent  - AS3

パッケージ flash.events

インターフェイス
IEventDispatcher
 
クラス
AccelerometerEvent
ActivityEvent
AsyncErrorEvent
AudioOutputChangeEvent
AVDictionaryDataEvent
AVHTTPStatusEvent
AVPauseAtPeriodEndEvent
BrowserInvokeEvent    
ContextMenuEvent
DataEvent
DatagramSocketDataEvent    
DeviceRotationEvent    
DNSResolverEvent    
DRMAuthenticateEvent    
DRMAuthenticationCompleteEvent
DRMAuthenticationErrorEvent
DRMDeviceGroupErrorEvent
DRMDeviceGroupEvent
DRMErrorEvent
DRMLicenseRequestEvent
DRMMetadataEvent
DRMReturnVoucherCompleteEvent
DRMReturnVoucherErrorEvent
DRMStatusEvent
ErrorEvent
Event
EventDispatcher
EventPhase
FileListEvent    
FocusEvent
FullScreenEvent
GameInputEvent    
GeolocationEvent
GestureEvent
GesturePhase
HTMLUncaughtScriptExceptionEvent    
HTTPStatusEvent
IMEEvent
InvokeEvent    
IOErrorEvent
KeyboardEvent
LocationChangeEvent    
MediaEvent    
MouseEvent
NativeDragEvent    
NativeProcessExitEvent    
NativeWindowBoundsEvent    
NativeWindowDisplayStateEvent    
NetDataEvent
NetMonitorEvent
NetStatusEvent
OutputProgressEvent    
PermissionEvent
PressAndTapGestureEvent
ProgressEvent
RemoteNotificationEvent    
SampleDataEvent
ScreenMouseEvent    
SecurityErrorEvent
ServerSocketConnectEvent    
ShaderEvent
SoftKeyboardEvent
SoftKeyboardTrigger
SQLErrorEvent    
SQLEvent    
SQLUpdateEvent    
StageOrientationEvent    
StageVideoAvailabilityEvent
StageVideoEvent
StatusEvent
StorageVolumeChangeEvent    
SyncEvent
TextEvent
ThrottleEvent
ThrottleType
TimerEvent
TouchEvent
TouchEventIntent    
TransformGestureEvent
UncaughtErrorEvent
UncaughtErrorEvents
VideoEvent
VideoTextureEvent
VsyncStateChangeAvailabilityEvent    
パッケージflash.events
クラスpublic class ContextMenuEvent
継承ContextMenuEvent Inheritance Event Inheritance Object

言語バージョン: ActionScript 3.0
ランタイムバージョン: AIR 1.0, Flash Player 9

ContextMenuEvent オブジェクトは、ユーザーがコンテキストメニューを開いたり操作したりするときに InteractiveObject によって送出されます。次の 2 種類の ContextMenuEvent オブジェクトがあります。
  • ContextMenuEvent.MENU_ITEM_SELECT
  • ContextMenuEvent.MENU_SELECT

例を表示

関連する API エレメント



パブリックプロパティ
 プロパティ定義元
 Inheritedbubbles : Boolean
[読み取り専用] イベントがバブリングイベントかどうかを示します。
Event
 Inheritedcancelable : Boolean
[読み取り専用] イベントに関連付けられた動作を回避できるかどうかを示します。
Event
 Inheritedconstructor : Object
指定されたオブジェクトインスタンスのクラスオブジェクトまたはコンストラクター関数への参照です。
Object
  contextMenuOwner : InteractiveObject
メニューが関連付けられている表示リストオブジェクトです。
ContextMenuEvent
 InheritedcurrentTarget : Object
[読み取り専用] イベントリスナーで Event オブジェクトをアクティブに処理しているオブジェクトです。
Event
 InheritedeventPhase : uint
[読み取り専用] イベントフローの現在の段階です。
Event
  isMouseTargetInaccessible : Boolean
mouseTarget プロパティがセキュリティ上の理由で null に設定されているかどうかを示します。
ContextMenuEvent
  mouseTarget : InteractiveObject
ユーザーがコンテキストメニューを表示するために右クリックした表示リストオブジェクトです。
ContextMenuEvent
 Inheritedtarget : Object
[読み取り専用] イベントターゲットです。
Event
 Inheritedtype : String
[読み取り専用] イベントのタイプです。
Event
パブリックメソッド
 メソッド定義元
  
ContextMenuEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, mouseTarget:InteractiveObject = null, contextMenuOwner:InteractiveObject = null)
メニューイベントに関する特定の情報を含む Event オブジェクトを作成します。
ContextMenuEvent
  
[オーバーライド] ContextMenuEvent オブジェクトのコピーを作成して、各プロパティの値を元のプロパティの値と一致するように設定します。
ContextMenuEvent
 Inherited
formatToString(className:String, ... arguments):String
カスタム ActionScript 3.0 Event クラスに toString() メソッドを実装するためのユーティリティ関数です。
Event
 Inherited
オブジェクトに指定されたプロパティが定義されているかどうかを示します。
Object
 Inherited
イベントで preventDefault() メソッドが呼び出されたかどうかを確認します。
Event
 Inherited
Object クラスのインスタンスが、パラメーターとして指定されたオブジェクトのプロトタイプチェーン内にあるかどうかを示します。
Object
 Inherited
イベントのデフォルト動作をキャンセルできる場合に、その動作をキャンセルします。
Event
 Inherited
指定されたプロパティが存在し、列挙できるかどうかを示します。
Object
 Inherited
ループ処理に対するダイナミックプロパティの可用性を設定します。
Object
 Inherited
イベントフローの現在のノードおよび後続するノードで、イベントリスナーが処理されないようにします。
Event
 Inherited
イベントフローの現在のノードに後続するノードで、イベントリスナーが処理されないようにします。
Event
 Inherited
ロケール固有の規則に従って書式設定された、このオブジェクトのストリング表現を返します。
Object
  
[オーバーライド] ContextMenuEvent オブジェクトのすべてのプロパティを含むストリングを返します。
ContextMenuEvent
 Inherited
指定されたオブジェクトのプリミティブな値を返します。
Object
パブリック定数
 定数定義元
  MENU_ITEM_SELECT : String = "menuItemSelect"
[静的] menuItemSelect イベントオブジェクトの type プロパティ値を定義します。
ContextMenuEvent
  MENU_SELECT : String = "menuSelect"
[静的] menuSelect イベントオブジェクトの type プロパティ値を定義します。
ContextMenuEvent
プロパティの詳細

contextMenuOwner

プロパティ
contextMenuOwner:InteractiveObject

言語バージョン: ActionScript 3.0
ランタイムバージョン: AIR 1.0, Flash Player 9

メニューが関連付けられている表示リストオブジェクトです。これは、マウスターゲット(mouseTarget)、または表示リストの祖先のいずれかになります。



実装
    public function get contextMenuOwner():InteractiveObject
    public function set contextMenuOwner(value:InteractiveObject):void

isMouseTargetInaccessible

プロパティ 
isMouseTargetInaccessible:Boolean

言語バージョン: ActionScript 3.0
ランタイムバージョン: AIR 1.0, Flash Player 10

mouseTarget プロパティがセキュリティ上の理由で null に設定されているかどうかを示します。menuTarget の公称値が別のセキュリティサンドボックスにある DisplayObject への参照である場合、このサンドボックスの境界をまたいで両方向に権限がある場合を除いては、menuTargetnull に設定されます。権限を確立するには、SWF ファイルから Security.allowDomain() を呼び出すか、イメージファイルのサーバーからポリシーファイルを提供し、LoaderContext.checkPolicyFile フラグを設定してイメージを読み込みます。



実装
    public function get isMouseTargetInaccessible():Boolean
    public function set isMouseTargetInaccessible(value:Boolean):void

関連する API エレメント

mouseTarget

プロパティ 
mouseTarget:InteractiveObject

言語バージョン: ActionScript 3.0
ランタイムバージョン: AIR 1.0, Flash Player 9

ユーザーがコンテキストメニューを表示するために右クリックした表示リストオブジェクトです。これは、メニューが関連付けられている表示リストオブジェクト(contextMenuOwner)、またはその表示リストの子孫のいずれかになります。

このプロパティの値は、マウスターゲットがない場合(例えばマウスが背景上にある場合)、またはマウスターゲットはあるがアクセスできないセキュリティサンドボックスの中にある場合の 2 つの状況の場合に、null になる可能性があります。isMouseTargetInaccessible() プロパティを使用して、どの理由が適用されるかを判別します。



実装
    public function get mouseTarget():InteractiveObject
    public function set mouseTarget(value:InteractiveObject):void

関連する API エレメント

コンストラクターの詳細

ContextMenuEvent

()コンストラクター
public function ContextMenuEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, mouseTarget:InteractiveObject = null, contextMenuOwner:InteractiveObject = null)

言語バージョン: ActionScript 3.0
ランタイムバージョン: AIR 1.0, Flash Player 9

メニューイベントに関する特定の情報を含む Event オブジェクトを作成します。イベントリスナーには Event オブジェクトがパラメーターとして渡されます。

パラメーター
type:String — イベントのタイプです。有効な値は次のとおりです。
  • ContextMenuEvent.MENU_ITEM_SELECT
  • ContextMenuEvent.MENU_SELECT
 
bubbles:Boolean (default = false) — Event オブジェクトがイベントフローのバブリング段階で処理されるかどうかを判断します。イベントリスナーは、継承された bubbles プロパティを通じてこの情報にアクセスできます。
 
cancelable:Boolean (default = false) — Event オブジェクトがキャンセル可能かどうかを判断します。イベントリスナーは、継承された cancelable プロパティを通じてこの情報にアクセスできます。
 
mouseTarget:InteractiveObject (default = null) — ユーザーがコンテキストメニューを表示するために右クリックした表示リストオブジェクトです。これは、contextMenuOwner、またはその表示リストの子孫のいずれかになります。
 
contextMenuOwner:InteractiveObject (default = null) — メニューが関連付けられている表示リストオブジェクトです。これは、mouseTarget、またはその表示リストの祖先のいずれかになります。

関連する API エレメント

メソッドの詳細

clone

()メソッド
override public function clone():Event

言語バージョン: ActionScript 3.0
ランタイムバージョン: AIR 1.0, Flash Player 9

ContextMenuEvent オブジェクトのコピーを作成して、各プロパティの値を元のプロパティの値と一致するように設定します。

戻り値
Event — 元のオブジェクトと同じプロパティ値を含む新しい ContextMenuEvent オブジェクトです。

toString

()メソッド 
override public function toString():String

言語バージョン: ActionScript 3.0
ランタイムバージョン: AIR 1.0, Flash Player 9

ContextMenuEvent オブジェクトのすべてのプロパティを含むストリングを返します。ストリングは次の形式です。

[ContextMenuEvent type= value bubbles= value cancelable= value ... contextMenuOwner= value ]

戻り値
String — ContextMenuEvent オブジェクトのすべてのプロパティを含むストリングです。
定数の詳細

MENU_ITEM_SELECT

定数
public static const MENU_ITEM_SELECT:String = "menuItemSelect"

言語バージョン: ActionScript 3.0
ランタイムバージョン: AIR 1.0, Flash Player 9

type プロパティ(menuItemSelect イベントオブジェクト)の値を定義します。

このイベントには、次のプロパティがあります。

プロパティ
bubblesfalse
cancelablefalse は、キャンセルするデフォルトの動作がないことを示します。
contextMenuOwnerメニューが関連付けられている表示リストオブジェクトです。
currentTargetイベントリスナーで Event オブジェクトをアクティブに処理しているオブジェクトです。
mouseTargetユーザーがコンテキストメニューを表示するために右クリックした表示リストオブジェクトです。
target選択された ContextMenuItem オブジェクトです。target は、必ずしもイベントリスナーを登録した表示リスト内のオブジェクトとは限りません。現在イベントを処理している表示リスト内のオブジェクトにアクセスするには、currentTarget プロパティを使用します。

関連する API エレメント

MENU_SELECT

定数 
public static const MENU_SELECT:String = "menuSelect"

言語バージョン: ActionScript 3.0
ランタイムバージョン: AIR 1.0, Flash Player 9

type プロパティ(menuSelect イベントオブジェクト)の値を定義します。

このイベントには、次のプロパティがあります。

プロパティ
bubblesfalse
cancelablefalse は、キャンセルするデフォルトの動作がないことを示します。
contextMenuOwnerメニューが関連付けられている表示リストオブジェクトです。
currentTargetイベントリスナーで Event オブジェクトをアクティブに処理しているオブジェクトです。
mouseTargetユーザーがコンテキストメニューを表示するために右クリックした表示リストオブジェクトです。
target表示される ContextMenu オブジェクトです。target は、必ずしもイベントリスナーを登録した表示リスト内のオブジェクトとは限りません。現在イベントを処理している表示リスト内のオブジェクトにアクセスするには、currentTarget プロパティを使用します。

関連する API エレメント

ContextMenuEventExample.as

次の例では、ContextMenuEventExample クラスを使用して、デフォルトのコンテキストメニューアイテムをステージから削除し、ステージ上の四角形の色を変更する新しいメニューアイテムを追加します。この例では、次の処理を実行します。
  1. myContextMenu プロパティが宣言され、新しい ContextMenu オブジェクトに割り当てられ、Sprite 型の redRectangle プロパティが宣言されます。
  2. removeDefaultItems() メソッドが呼び出されます。このメソッドによって、すべてのビルトインコンテキストメニューアイテムが削除されます。ただし、プリントを除きます。
  3. addCustomMenuItems() メソッドが呼び出されます。このメソッドによって、Reverse Colors メニューアイテムが defaultItems 配列に配置されます。配列の push() メソッドが使用されます。menuItemSelect イベントリスナーが ContextMenuItem オブジェクトに追加されます。関連付けられるメソッドは menuItemSelectHandler() という名前です。このメソッドは、ユーザーがコンテキストメニューから「色の反転」を選択すると必ず trace() ステートメントを出力します。また、赤い四角形は黒に変わり、黒のテキストは赤に変わります。
  4. コンストラクターに戻り、menuSelect イベントリスナーが、関連するメソッド menuSelectHandler() と共に追加されます。このメソッドは、コンテキストメニューのアイテムが選択されるたびに 3 つの trace() ステートメントを出力します。
  5. コンストラクターは addChildren() を呼び出します。これは、赤色の四角形を描画し、その四角形を表示リストに追加します。この四角形は、表示リストにすぐに表示されます。
  6. 最後に、myContextMenuredRectangle プロパティのコンテキストメニューに割り当てられます。このため、カスタムコンテキストメニューが表示されるのは、マウスポインターが四角形の上にある場合のみです。
package {
    import flash.ui.ContextMenu;
    import flash.ui.ContextMenuItem;
    import flash.ui.ContextMenuBuiltInItems;
    import flash.events.ContextMenuEvent;
    import flash.display.Sprite;
    import flash.display.Shape;
    import flash.text.TextField;

    public class ContextMenuEventExample extends Sprite {
        private var myContextMenu:ContextMenu;
        private var menuLabel:String = "Reverse Colors";
        private var textLabel:String = "Right Click";
        private var redRectangle:Sprite;
        private var label:TextField;
        private var size:uint = 100;
        private var black:uint = 0x000000;
        private var red:uint = 0xFF0000;

        public function ContextMenuEventExample() {
            myContextMenu = new ContextMenu();
            removeDefaultItems();
            addCustomMenuItems();
            myContextMenu.addEventListener(ContextMenuEvent.MENU_SELECT, menuSelectHandler);

            addChildren();
            redRectangle.contextMenu = myContextMenu;
        }

        private function addChildren():void {
            redRectangle = new Sprite();
            redRectangle.graphics.beginFill(red);
            redRectangle.graphics.drawRect(0, 0, size, size);
            addChild(redRectangle);
            redRectangle.x = size;
            redRectangle.y = size;
            label = createLabel();
            redRectangle.addChild(label);
        }

        private function removeDefaultItems():void {
            myContextMenu.hideBuiltInItems();
            var defaultItems:ContextMenuBuiltInItems = myContextMenu.builtInItems;
            defaultItems.print = true;
        }

        private function addCustomMenuItems():void {
            var item:ContextMenuItem = new ContextMenuItem(menuLabel);
            myContextMenu.customItems.push(item);
            item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, menuItemSelectHandler);
        }

        private function menuSelectHandler(event:ContextMenuEvent):void {
            trace("menuSelectHandler: " + event);
        }

        private function menuItemSelectHandler(event:ContextMenuEvent):void {
            trace("menuItemSelectHandler: " + event);
            var textColor:uint = (label.textColor == black) ? red : black;
            var bgColor:uint = (label.textColor == black) ? black : red;
            redRectangle.graphics.clear();
            redRectangle.graphics.beginFill(bgColor);
            redRectangle.graphics.drawRect(0, 0, size, size);
            label.textColor = textColor;
        }

        private function createLabel():TextField {
            var txtField:TextField = new TextField();
            txtField.text = textLabel;
            return txtField;
        }
    }
}




[ X ]英語で表示される理由
ActionScript 3.0 リファレンスガイドのコンテンツが英語で表示されます。

ActionScript 3.0 リファレンスガイドのすべての部分がすべての言語に翻訳されているわけではありません。言語エレメントが翻訳されていない場合、そのエレメントは英語で表示されます。例えば、ga.controls.HelpBox クラスはどの言語にも訳されていません。このため、リファレンスガイドの日本語バージョンでは、ga.controls.HelpBox クラスは英語で表示されます。