패키지flash.events
클래스public class ContextMenuEvent
상속ContextMenuEvent Inheritance Event Inheritance Object

언어 버전 : ActionScript 3.0
Player 버전 : Flash Player 9

사용자가 컨텍스트 메뉴를 열거나 조작하면 Flash(r) Player는 ContextMenuEvent 객체를 전달합니다. 컨텍스트 메뉴는 포인팅 장치(보통 마우스 또는 트랙볼)의 보조 버튼을 클릭하여 엽니다. ContextMenuEvent 객체에는 다음 두 가지 유형이 있습니다.

예제를 통해 확인하십시오.

참고 사항

ContextMenu class
ContextMenuItem class


Public 속성
 속성다음에 의해 정의됨
 Inheritedbubbles : Boolean
[read-only] 이벤트가 버블링 이벤트인지 여부를 나타냅니다.
Event
 Inheritedcancelable : Boolean
[read-only] 해당 이벤트와 연관된 비헤이비어를 차단할 수 있는지 여부를 나타냅니다.
Event
 Inheritedconstructor : Object
지정된 객체 인스턴스의 클래스 객체 또는 생성자 함수에 대한 참조입니다.
Object
  contextMenuOwner : InteractiveObject
메뉴가 연결된 표시 목록 객체입니다.
ContextMenuEvent
 InheritedcurrentTarget : Object
[read-only] 현재 이벤트 리스너를 통해 Event 객체를 처리하고 있는 객체입니다.
Event
 InheritedeventPhase : uint
[read-only] 이벤트 흐름에서 현재 단계입니다.
Event
  mouseTarget : InteractiveObject
사용자가 컨텍스트 메뉴를 표시하기 위해 마우스 오른쪽 버튼으로 클릭한 표시 목록 객체입니다.
ContextMenuEvent
 Inheritedprototype : Object
[static] 클래스 또는 함수 객체의 프로토타입 객체에 대한 참조입니다.
Object
 Inheritedtarget : Object
[read-only] 이벤트 대상입니다.
Event
 Inheritedtype : String
[read-only] 이벤트 유형입니다.
Event
Public 메서드
 메서드다음에 의해 정의됨
  
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
사용자 정의 Event 클래스에서 toString() 메서드를 구현하기 위한 유틸리티 함수입니다.
Event
 Inherited
지정된 속성이 객체에 정의되어 있는지 여부를 나타냅니다.
Object
 Inherited
이벤트에서 preventDefault()가 호출되었는지 여부를 확인합니다.
Event
 Inherited
Object 클래스의 인스턴스가 매개 변수로 지정된 객체의 프로토타입 체인에 있는지 여부를 나타냅니다.
Object
 Inherited
이벤트의 기본 비헤이비어를 취소할 수 있는 경우, 그 비헤이비어를 취소합니다.
Event
 Inherited
지정된 속성이 존재하고 열거 가능한지 여부를 나타냅니다.
Object
 Inherited
루프 작업에서 동적 속성을 사용할 수 있는지 여부를 설정합니다.
Object
 Inherited
이벤트 흐름에서 현재 노드 및 그 후속 노드에 있는 모든 이벤트 리스너가 처리되지 않도록 합니다.
Event
 Inherited
이벤트 흐름에서 현재 노드의 후속 노드에 있는 모든 이벤트 리스너가 처리되지 않도록 합니다.
Event
  
ContextMenuEvent 객체의 속성이 모두 포함된 문자열을 반환합니다.
ContextMenuEvent
 Inherited
지정된 객체의 프리미티브 값을 반환합니다.
Object
Public 상수
 상수다음에 의해 정의됨
 InheritedACTIVATE : String = "activate"
[static] activate 이벤트 객체의 type 속성 값을 정의합니다.
Event
 InheritedADDED : String = "added"
[static] added 이벤트 객체의 type 속성 값을 정의합니다.
Event
 InheritedADDED_TO_STAGE : String = "addedToStage"
[static] addedToStage 이벤트 객체의 type 속성 값을 정의합니다.
Event
 InheritedCANCEL : String = "cancel"
[static] cancel 이벤트 객체의 type 속성 값을 정의합니다.
Event
 InheritedCHANGE : String = "change"
[static] change 이벤트 객체의 type 속성 값을 정의합니다.
Event
 InheritedCLOSE : String = "close"
[static] close 이벤트 객체의 type 속성 값을 정의합니다.
Event
 InheritedCOMPLETE : String = "complete"
[static] complete 이벤트 객체의 type 속성 값을 정의합니다.
Event
 InheritedCONNECT : String = "connect"
[static] connect 이벤트 객체의 type 속성 값을 정의합니다.
Event
 InheritedDEACTIVATE : String = "deactivate"
[static] deactivate 이벤트 객체의 type 속성 값을 정의합니다.
Event
 InheritedENTER_FRAME : String = "enterFrame"
[static] enterFrame 이벤트 객체의 type 속성 값을 정의합니다.
Event
 InheritedFULLSCREEN : String = "fullScreen"
[static] fullScreen 이벤트 객체의 type 속성 값을 정의합니다.
Event
 InheritedID3 : String = "id3"
[static] id3 이벤트 객체의 type 속성 값을 정의합니다.
Event
 InheritedINIT : String = "init"
[static] init 이벤트 객체의 type 속성 값을 정의합니다.
Event
  MENU_ITEM_SELECT : String = "menuItemSelect"
[static] menuItemSelect 이벤트 객체의 type 속성 값을 정의합니다.
ContextMenuEvent
  MENU_SELECT : String = "menuSelect"
[static] menuSelect 이벤트 객체의 type 속성 값을 정의합니다.
ContextMenuEvent
 InheritedMOUSE_LEAVE : String = "mouseLeave"
[static] mouseLeave 이벤트 객체의 type 속성 값을 정의합니다.
Event
 InheritedOPEN : String = "open"
[static] open 이벤트 객체의 type 속성 값을 정의합니다.
Event
 InheritedREMOVED : String = "removed"
[static] removed 이벤트 객체의 type 속성 값을 정의합니다.
Event
 InheritedREMOVED_FROM_STAGE : String = "removedFromStage"
[static] removedFromStage 이벤트 객체의 type 속성 값을 정의합니다.
Event
 InheritedRENDER : String = "render"
[static] render 이벤트 객체의 type 속성 값을 정의합니다.
Event
 InheritedRESIZE : String = "resize"
[static] resize 이벤트 객체의 type 속성 값을 정의합니다.
Event
 InheritedSCROLL : String = "scroll"
[static] scroll 이벤트 객체의 type 속성 값을 정의합니다.
Event
 InheritedSELECT : String = "select"
[static] select 이벤트 객체의 type 속성 값을 정의합니다.
Event
 InheritedSOUND_COMPLETE : String = "soundComplete"
[static] soundComplete 이벤트 객체의 type 속성 값을 정의합니다.
Event
 InheritedTAB_CHILDREN_CHANGE : String = "tabChildrenChange"
[static] tabChildrenChange 이벤트 객체의 type 속성 값을 정의합니다.
Event
 InheritedTAB_ENABLED_CHANGE : String = "tabEnabledChange"
[static] tabEnabledChange 이벤트 객체의 type 속성 값을 정의합니다.
Event
 InheritedTAB_INDEX_CHANGE : String = "tabIndexChange"
[static] tabIndexChange 이벤트 객체의 type 속성 값을 정의합니다.
Event
 InheritedUNLOAD : String = "unload"
[static] unload 이벤트 객체의 type 속성 값을 정의합니다.
Event
속성 정보
contextMenuOwner속성
contextMenuOwner:InteractiveObject  [read-write]

언어 버전 : ActionScript 3.0
Player 버전 : Flash Player 9

메뉴가 연결된 표시 목록 객체입니다. 이것은 마우스 대상(mouseTarget)이거나 표시 목록에 있는 그 조상 중 하나일 수 있습니다.


구현
    public function get contextMenuOwner():InteractiveObject
    public function set contextMenuOwner(value:InteractiveObject):void
mouseTarget속성 
mouseTarget:InteractiveObject  [read-write]

언어 버전 : ActionScript 3.0
Player 버전 : Flash Player 9

사용자가 컨텍스트 메뉴를 표시하기 위해 마우스 오른쪽 버튼으로 클릭한 표시 목록 객체입니다. 이것은 메뉴가 연결된 표시 목록 객체(contextMenuOwner)이거나 표시 목록에 있는 그 자손 중 하나일 수 있습니다.


구현
    public function get mouseTarget():InteractiveObject
    public function set mouseTarget(value:InteractiveObject):void
생성자 정보
ContextMenuEvent()생성자
public function ContextMenuEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, mouseTarget:InteractiveObject = null, contextMenuOwner:InteractiveObject = null)

언어 버전 : ActionScript 3.0
Player 버전 : 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이거나 표시 목록에 있는 그 조상 중 하나일 수 있습니다.

참고 사항

메서드 정보
clone()메서드
public override function clone():Event

언어 버전 : ActionScript 3.0
Player 버전 : Flash Player 9

ContextMenuEvent 객체의 복사본을 하나 만들고 각 속성의 값을 원본과 동일하게 설정합니다.

반환값
Event — 원본과 동일한 속성 값을 갖는 새 ContextMenuEvent 객체입니다.
toString()메서드 
public override function toString():String

언어 버전 : ActionScript 3.0
Player 버전 : 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
Player 버전 : Flash Player 9

menuItemSelect 이벤트 객체의 type 속성 값을 정의합니다.

이 이벤트에는 다음과 같은 속성이 있습니다.

속성
bubblesfalse
cancelablefalse; 취소할 기본 비헤이비어가 없습니다.
contextMenuOwner메뉴가 연결된 표시 목록 객체입니다.
currentTarget현재 이벤트 리스너를 통해 Event 객체를 처리하고 있는 객체입니다.
mouseTarget사용자가 컨텍스트 메뉴를 표시하기 위해 마우스 오른쪽 버튼으로 클릭한 표시 목록 객체입니다.
target선택한 ContextMenuItem 객체입니다. target은 표시 목록에서 이벤트 리스너를 등록한 객체가 아닐 수도 있습니다. 표시 목록에서 현재 이벤트를 처리 중인 객체에 액세스하려면 currentTarget 속성을 사용합니다.

참고 사항

MENU_SELECT상수 
public static const MENU_SELECT:String = "menuSelect"

언어 버전 : ActionScript 3.0
Player 버전 : Flash Player 9

menuSelect 이벤트 객체의 type 속성 값을 정의합니다.

이 이벤트에는 다음과 같은 속성이 있습니다.

속성
bubblesfalse
cancelablefalse; 취소할 기본 비헤이비어가 없습니다.
contextMenuOwner메뉴가 연결된 표시 목록 객체입니다.
currentTarget현재 이벤트 리스너를 통해 Event 객체를 처리하고 있는 객체입니다.
mouseTarget사용자가 컨텍스트 메뉴를 표시하기 위해 마우스 오른쪽 버튼으로 클릭한 표시 목록 객체입니다.
target표시될 ContextMenu 객체입니다. target은 표시 목록에서 이벤트 리스너를 등록한 객체가 아닐 수도 있습니다. 표시 목록에서 현재 이벤트를 처리 중인 객체에 액세스하려면 currentTarget 속성을 사용합니다.

참고 사항

예제 예제 사용 방법
ContextMenuEventExample.as

다음 예제에서는 ContextMenuEventExample 클래스를 사용하여 스테이지에서 기본 컨텍스트 메뉴 항목을 제거하고, 스테이지에 있는 사각형의 색상을 변경하는 새 메뉴 항목을 추가합니다. 이는 다음 단계로 이루어집니다.
  1. myContextMenu 속성이 선언되어 새 ContextMenu 객체에 할당되고 redRectangle 속성(Sprite 유형)이 선언됩니다.
  2. removeDefaultItems() 메서드가 호출됩니다. 이 메서드는 인쇄를 제외한 모든 내장 컨텍스트 메뉴 항목을 제거합니다.
  3. addCustomMenuItems() 메서드가 호출됩니다. 이 메서드는 Array의 push() 메서드를 사용하여 Reverse Colors 메뉴 항목을 defaultItems 배열에 배치합니다. menuItemSelect 이벤트 리스너가 ContextMenuItem 객체에 추가되고, 연관된 메서드 menuItemSelectHandler()가 호출됩니다. 이 메서드는 사용자가 컨텍스트 메뉴에서 색상 반전을 선택할 때마다 trace() 문을 출력합니다. 빨간색 사각형은 검정색으로, 검정색 텍스트는 빨간색으로 반전시킵니다.
  4. 다시 생성자에서, 컨텍스트 메뉴의 항목이 선택될 때마다 세 개의 trace() 문을 출력하는 연관된 메서드 menuSelectHandler()와 함께 menuSelect 이벤트 리스너가 추가됩니다.
  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;
        }
    }
}




 

이 페이지에 의견 추가되면 전자 메일 알림 받기 | 의견 보고서

현재 페이지: http://livedocs.adobe.com/flash/9.0_kr/ActionScriptLangRefV3/flash/events/ContextMenuEvent.html