패키지flash.ui
클래스public final class ContextMenuItem
상속ContextMenuItem Inheritance EventDispatcher Inheritance Object

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

ContextMenuItem 클래스를 사용하면 Flash Player 컨텍스트 메뉴에 표시할 사용자 정의 메뉴 항목을 만들 수 있습니다. 각 ContextMenuItem 객체에는 컨텍스트 메뉴에 표시되는 텍스트 캡션이 있습니다. 컨텍스트 메뉴에 새 항목을 추가하려면 이를 ContextMenu 객체의 customItems 배열에 추가합니다.

ContextMenuItem 클래스의 속성을 사용하면 특정 메뉴 항목을 활성화하거나 비활성화할 수 있고 항목을 표시하거나 숨길 수 있습니다.

menuItemSelect 이벤트에 대한 이벤트 핸들러를 작성하여 사용자가 메뉴 항목을 선택할 때 실행할 기능을 추가합니다.

사용자 정의 메뉴 항목은 컨텍스트 메뉴의 맨 위에, 내장 항목 위에 표시됩니다. 사용자 정의 메뉴 항목과 내장 항목 사이에는 항상 구분 표시줄이 표시됩니다.

여기에는 다음과 같은 제한이 있습니다.

참고: 영어를 사용하지 않는 시스템에서 Flash Player를 실행하는 경우 캡션 문자열은 영어 목록 및 지역화된 해당 문자열 모두와 비교됩니다.

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

참고 사항

ContextMenu class
ContextMenuBuiltInItems class


Public 속성
 속성다음에 의해 정의됨
  caption : String
컨텍스트 메뉴에 표시될 메뉴 항목 캡션 텍스트를 지정합니다.
ContextMenuItem
 Inheritedconstructor : Object
지정된 객체 인스턴스의 클래스 객체 또는 생성자 함수에 대한 참조입니다.
Object
  enabled : Boolean
지정된 메뉴 항목의 활성화 여부를 나타냅니다.
ContextMenuItem
 Inheritedprototype : Object
[static] 클래스 또는 함수 객체의 프로토타입 객체에 대한 참조입니다.
Object
  separatorBefore : Boolean
지정된 메뉴 항목 위에 구분 표시줄을 표시할지 여부를 나타냅니다.
ContextMenuItem
  visible : Boolean
Flash Player 컨텍스트 메뉴가 표시될 때 지정된 메뉴 항목이 표시되는지 여부를 나타냅니다.
ContextMenuItem
Public 메서드
 메서드다음에 의해 정의됨
  
ContextMenuItem(caption:String, separatorBefore:Boolean = false, enabled:Boolean = true, visible:Boolean = true)
ContextMenu.customItems 배열에 추가할 수 있는 새 ContextMenuItem 객체를 만듭니다.
ContextMenuItem
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
리스너에서 이벤트 알림을 받을 수 있도록 EventDispatcher 객체에 이벤트 리스너 객체를 등록합니다.
EventDispatcher
  
지정된 ContextMenuItem 객체의 복사본을 만들고 반환합니다.
ContextMenuItem
 Inherited
이벤트를 이벤트 흐름으로 전달합니다.
EventDispatcher
 Inherited
EventDispatcher 객체에 특정 유형의 이벤트에 대한 리스너가 등록되어 있는지 여부를 확인합니다.
EventDispatcher
 Inherited
지정된 속성이 객체에 정의되어 있는지 여부를 나타냅니다.
Object
 Inherited
Object 클래스의 인스턴스가 매개 변수로 지정된 객체의 프로토타입 체인에 있는지 여부를 나타냅니다.
Object
 Inherited
지정된 속성이 존재하고 열거 가능한지 여부를 나타냅니다.
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
EventDispatcher 객체에서 리스너를 제거합니다.
EventDispatcher
 Inherited
루프 작업에서 동적 속성을 사용할 수 있는지 여부를 설정합니다.
Object
 Inherited
지정된 객체의 문자열 표현을 반환합니다.
Object
 Inherited
지정된 객체의 프리미티브 값을 반환합니다.
Object
 Inherited
이 EventDispatcher 객체 또는 조상 객체에 지정한 이벤트 유형에 대한 이벤트 리스너가 등록되어 있는지 여부를 확인합니다.
EventDispatcher
이벤트
 이벤트 요약 다음에 의해 정의됨
 Inherited Flash Player가 운영 체제에서 포커스를 얻어 활성화될 때 전달됩니다.EventDispatcher
 Inherited 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
ContextMenuEvent.type property = flash.events.ContextMenuEvent.MENU_ITEM_SELECT

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

사용자가 컨텍스트 메뉴에서 항목을 선택할 때 전달됩니다. 사용자는 포인팅 장치의 보조 버튼을 클릭하여 컨텍스트 메뉴를 생성합니다.

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

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

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

다음 예제에서는 ContextMenuBuiltInItemsExample 클래스를 사용하여 스테이지에서 기본 컨텍스트 메뉴 항목을 제거하고 새 메뉴 항목을 추가합니다. 이는 다음 단계로 이루어집니다.
  1. myContextMenu 속성을 선언하여 새 ContextMenu 객체에 할당합니다.
  2. removeDefaultItems() 메서드를 호출하여 인쇄를 제외한 모든 내장 컨텍스트 메뉴 항목을 제거합니다.
  3. addCustomMenuItems() 메서드를 호출하여 Hello World라는 메뉴 항목을 customItems 배열에 추가합니다. 이때 배열의 push() 메서드를 사용합니다.
  4. Hello World 컨텍스트 메뉴 항목이 스테이지의 컨텍스트 메뉴 항목 목록에 추가됩니다.
  5. "Right Click Here"라는 텍스트가 포함된 TextField 객체가 스테이지에 추가됩니다.
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_kr/ActionScriptLangRefV3/flash/ui/ContextMenuItem.html