代码 复制 - 运行
varcontextMenu:ContextMenu=newContextMenu();
contextMenu.hideBuiltInItems();//隐藏一些内建的鼠标右键菜单项
<script>
functiononNsRightClick(e){
if(e.which==3){
FlexTest.openRightClick();
e.stopPropagation();
}
returnfalse;
}
functiononIeRightClick(e){
if(event.button>1){
FlexTest.openRightClick();
parent.frames.location.replace(javascript:parent.falseframe);
}
returnfalse;
}
if(navigator.appName=="Netscape"){
document.captureEvents(Event.MOUSEDOWN);
document.addEventListener("mousedown",onNsRightClick,true);
}
else{
document.οnmοusedοwn=onIeRightClick;
}
script>
2,修改FLEX的MXML
importmx.events.MenuEvent;
importmx.controls.Alert;
privatevarmouseTarget:DisplayObject;
functioninit()
{
ExternalInterface.addCallback("openRightClick",openRightClick);
}
functiongetMouseTarget(event:MouseEvent):void
{
mouseTarget=DisplayObject(event.target);
}
functionopenRightClick():void
{
vare:MouseEvent=newMouseEvent(MouseEvent.MOUSE_DOWN,true,false,mouseTarget.mouseX,mouseTarget.mouseY);
mouseTarget.dispatchEvent(e);
}
functionshowMouseEvent(event)
{
if(event.buttonDown==true)
Alert.show("Left");
else
Alert.show("Right");
}
AC_FL_RunContent(
"src","playerProductInstall",
"FlashVars","MMredirectURL="+MMredirectURL+&MMplayerType=+MMPlayerType+
&MMdoctitle=+MMdoctitle+"",
"width","100%",
"height","100%",
"align","middle",
"id","FlexTest",OBJECTID
"wmode","opaque",//注意:这里是关键
"quality","high",
"bgcolor","#869ca7",
"name","FlexTest",
"allowscriptAccess","sameDomain",
"type","application/x-shockwave-flash",
"pluginspage","http://www.adobe.com/go/getflashplayer"
);
event.stopPropagation();
event.cancelBubble=true;
因此还需要对浏览器进行一下判断,我没有装IE7,也就没有测,需要的朋友可以测试一下