|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
将多个Flash作品转化为屏保程序。◇所生成的屏保程序能进行全屏预览、窗口预览、设置密码等操作。
poluoluo中心提醒:网页FLASH动画克制右键菜单的办法.
在做一个实行时碰到一个克制flash的右键功效的成绩。在网上找了良多办法,要不就完整不可,要不就扫瞄器不兼容。Google了一下外洋的情形,终究找到了一个不错的办法。该办法用了javascript和as的分离,完善办理了成绩。
以下是javascript部分代码:
varRightClick={
/**
*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){returnfalse;}else{RightClick.Cache=“nan”;}}
document.getElementById(this.FlashContainerID).onmousedown=RightClick.onIEMouse;
}
},
/**
*GECKO/WEBKITeventoverkill
*@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/WEBKITcallrightclick
*@param{Object}ev
*/
onGeckoMouse:function(ev){
returnfunction(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;
}
}
},
/**
*IEcallrightclick
*@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;
}
},
/**
*MaincalltoFlashExternalInterface
*/
call:function(){
document.getElementById(this.FlashObjectID).rightClick();
}
}- varRightClick={/***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){returnfalse;}else{RightClick.Cache="nan";}}document.getElementById(this.FlashContainerID).onmousedown=RightClick.onIEMouse;}},/***GECKO/WEBKITeventoverkill*@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/WEBKITcallrightclick*@param{Object}ev*/onGeckoMouse:function(ev){returnfunction(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;}}},/***IEcallrightclick*@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;}},/***MaincalltoFlashExternalInterface*/call:function(){document.getElementById(this.FlashObjectID).rightClick();}}
复制代码 以下是as部分代码:
package{
importflash.display.*;
importflash.external.ExternalInterface;
publicclassclassRightClickextendsSprite
{
publicfunctionRightClick()
{
stage.scaleMode=StageScaleMode.NO_SCALE;
stage.align=StageAlign.TOP_LEFT;
varmethodName:String=“rightClick”;
varmethod:Function=onRightClick;
ExternalInterface.addCallback(methodName,method);
}
privatefunctiononRightClick():void{
varmx:int=stage.mouseX;
varmy:int=stage.mouseY;
if(my>0&&my<stage.stageHeight&&mx>0&&mx<stage.stageWidth){
//YOURCODEHERE
}
}
}
- package{importflash.display.*;importflash.external.ExternalInterface;publicclassclassRightClickextendsSprite{publicfunctionRightClick(){stage.scaleMode=StageScaleMode.NO_SCALE;stage.align=StageAlign.TOP_LEFT;varmethodName:String="rightClick";varmethod:Function=onRightClick;ExternalInterface.addCallback(methodName,method);}privatefunctiononRightClick():void{varmx:int=stage.mouseX;varmy:int=stage.mouseY;if(my>0&&my0&&mx
复制代码 撑持的扫瞄器有:
WINDOWSVISTA
- InternetExplorer7.0.6001(16549)
- Firefox2.0.0.6(withmousegesturesdisabled)
- Maxthon2(withmousegesturesdisabled)
- Safari3.0.3(522.15.5)
WindowsXPSP2
- InternetExplorer6
- InternetExplorer7
- Maxthon2(withmousegesturesdisabled)
- FireFox2(withmousegesturesdisabled)
- Safari3
- Netscape8
MacOSX10.4.10(Intel)
这个播放器非常小,只需花一点点时间下载,对于在体验网页上的多媒体效果是个很好的开始。 |
|