자바스크립
-
/**
-
*
-
* Copyright 2007
-
*
-
* Paulius Uza
-
* http://www.uza.lt
-
*
-
* Dan Florio
-
* http://www.polygeek.com
-
*
-
* Project website:
-
* http://code.google.com/p/custom-context-menu/
-
*
-
* --
-
* RightClick for Flash Player.
-
* Version 0.6.2
-
*
-
*/
-
-
var RightClick = {
-
/**
-
* Constructor
-
*/
-
init: function () {
-
this.FlashObjectID = "customRightClick";
-
this.FlashContainerID = "flashcontent";
-
this.Cache = this.FlashObjectID;
-
if(window.addEventListener){
-
window.addEventListener("mousedown", this.onGeckoMouse(), true);
-
} else {
-
document.getElementById(this.FlashContainerID).onmouseup = function() { document.getElementById(RightClick.FlashContainerID).releaseCapture(); }
-
document.oncontextmenu = function(){ if(window.event.srcElement.id == RightClick.FlashObjectID) { return false; } else { RightClick.Cache = "nan"; }}
-
document.getElementById(this.FlashContainerID).onmousedown = RightClick.onIEMouse;
-
}
-
},
-
/**
-
* GECKO / WEBKIT event overkill
-
* @param {Object} eventObject
-
*/
-
killEvents: function(eventObject) {
-
if(eventObject) {
-
if (eventObject.stopPropagation) eventObject.stopPropagation();
-
if (eventObject.preventDefault) eventObject.preventDefault();
-
if (eventObject.preventCapture) eventObject.preventCapture();
-
if (eventObject.preventBubble) eventObject.preventBubble();
-
}
-
},
-
/**
-
* GECKO / WEBKIT call right click
-
* @param {Object} ev
-
*/
-
onGeckoMouse: function(ev) {
-
return function(ev) {
-
if (ev.button != 0) {
-
RightClick.killEvents(ev);
-
if(ev.target.id == RightClick.FlashObjectID && RightClick.Cache == RightClick.FlashObjectID) {
-
RightClick.call();
-
}
-
RightClick.Cache = ev.target.id;
-
}
-
}
-
},
-
/**
-
* IE call right click
-
* @param {Object} ev
-
*/
-
onIEMouse: function() {
-
if (event.button> 1) {
-
if(window.event.srcElement.id == RightClick.FlashObjectID && RightClick.Cache == RightClick.FlashObjectID) {
-
RightClick.call();
-
}
-
document.getElementById(RightClick.FlashContainerID).setCapture();
-
if(window.event.srcElement.id)
-
RightClick.Cache = window.event.srcElement.id;
-
}
-
},
-
/**
-
* Main call to Flash External Interface
-
*/
-
call: function() {
-
document.getElementById(this.FlashObjectID).rightClick();
-
}
-
}
-
package {
-
-
import flash.display.*;
-
import flash.external.ExternalInterface;
-
-
public class RightClick extends Sprite
-
{
-
-
public function RightClick()
-
{
-
stage.scaleMode = StageScaleMode.NO_SCALE;
-
stage.align = StageAlign.TOP_LEFT;
-
-
var methodName:String = "rightClick";
-
var method:Function = onRightClick;
-
ExternalInterface.addCallback(methodName, method);
-
}
-
-
private function onRightClick():void {
-
-
var mx:int = stage.mouseX;
-
var my:int = stage.mouseY;
-
-
if(my> 0 && my <stage.stageHeight && mx> 0 && mx <stage.stageWidth) {
-
// YOUR CODE HERE
-
}
-
}
-
}
-
}
출처
demo url : http://www.uza.lt/rightclick/
project url : http://code.google.com/p/custom-context-menu/
original post : http://www.uza.lt/blog/2007/08/solved-right-click-in-as3/
'ActionScript > AS3.0' 카테고리의 다른 글
Event 클래스의 속성 target 과 currentTarget의 차이점. (1) | 2008.03.31 |
---|---|
DisplaceMentMapFilter Class (5) | 2008.03.24 |
Focus selected shape (0) | 2008.03.24 |
모든 마우스 리스너 삭제 (0) | 2008.03.24 |
FileReferenceList 클래스를 이용한 multi_Upload (0) | 2008.03.24 |