index.fla:
import flash.text.TextField;
var _txt:TextField=new TextField;
_txt.text="请用右键点我"
addChild(_txt);
var i=0;
function displayMessage() {
i++;
_txt.text=i+"";
}
ExternalInterface.addCallback("showMessage", displayMessage);
***************************很丑的分隔线*****************************
test.htm:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>index</title>
<script>
//非ie----------------------------------
function mouseEvent_ns(e) {
//alert(e.button)
//firefox测得0是左键,1是中键,2是右键
if (e.button ==2) {
if (e) {
//屏蔽弹出
if (e.stopPropagation) {
e.stopPropagation();
}
if (e.preventDefault) {
e.preventDefault();
}
if (e.preventCapture) {
e.preventCapture();
}
if (e.preventBubble) {
e.preventBubble();
}
}
//调用as函数
thisMovie("index").showMessage();
}
}
function RightMouseUp_ns(e) {
mouseEvent_ns(e);
return false;
}
function downRightClick_ns(e) {
mouseEvent_ns(e);
return false;
}
//ie----------------------------------
function mouseEvent_ie() {
//alert(event.button)
//1是左键,4是中键,2是右键,但不知为什么遨游里按下没反应,弹起时先是得到0再得到2,遗憾...
if (event.button != 1&&event.button != 4) {
//调用as函数
thisMovie("index").showMessage();
//屏蔽弹出
thisMovie("index").openRightClick();
parent.frames.location.replace('javascript: parent.falseframe');
}
}
function RightMouseUp_ie() {
mouseEvent_ie()
return false;
}
function RightMouseDown_ie(e) {
mouseEvent_ie()
return false;
}
//得到播放器对象---------------------------------------
function thisMovie(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName];
} else {
return document[movieName];
}
}
//触发鼠标事件-----------------------------------------
this.ns = (navigator.appName == 'Netscape');
if (this.ns) {
document.captureEvents(Event.MOUSEDOWN);
document.addEventListener("mousedown", downRightClick_ns, true);
document.captureEvents(Event.MOUSEUP);
document.addEventListener("mouseup", RightMouseUp_ns, true);
} else {
document.onmousedown = RightMouseDown_ie;
document.onmouseup = RightMouseUp_ie;
}
</script>
</head>
<body bgcolor="#ffffff" topmargin="0" leftmargin="0" marginwidth="0">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="900" height="500" id="index" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="index.swf" />
<param name="menu" value="false" />
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<param name="bgcolor" value="#ffffff" />
<embed src="index.swf" menu="false" quality="high" wmode="opaque" bgcolor="#ffffff" width="900" height="500" name="index" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</body>
</html>
***************************很丑的分隔线*****************************
细心的人还会发现ie里鼠标点快了会有检测丢失的情况,又一遗憾,不过总归可以稍微利用下了吧
测试地址:




