再见西城 发表于 2015-1-15 22:48:32

来看看:网页FLASH动画克制右键菜单的办法-Flash actionscript

将多个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)


[*]Firefox2
[*]Safari3.0.3

这个播放器非常小,只需花一点点时间下载,对于在体验网页上的多媒体效果是个很好的开始。

变相怪杰 发表于 2015-1-17 18:49:40

随着动画的日益发展壮大,动画片在世界范围影响里越来越大,广告、网页、电影各个方面都应用到了动画。

小魔女 发表于 2015-1-26 21:40:40

flash的优缺点可以如何运用呢?

admin 发表于 2015-2-5 03:56:04

不过,要说国内在FLASH动画领域做的比较出色的,公认的是广州形动数码科技。

仓酷云 发表于 2015-2-11 04:47:32

Flash是一种以向量图方式制成的网页动画,相比MPEG,AVI等的影片的档案大小就小很多.

愤怒的大鸟 发表于 2015-3-1 22:04:07

在Web上只好把动画做得很小。即使最简单的动画也需要较长的下载时间。Flash的流技术和矢量图形对这种情况做了改变。

再现理想 发表于 2015-3-11 02:19:40

flash制作的动画文件比较小,可以在网络上快速传播!

老尸 发表于 2015-3-17 20:29:00

在Web上只好把动画做得很小。即使最简单的动画也需要较长的下载时间。Flash的流技术和矢量图形对这种情况做了改变。

只想知道 发表于 2015-3-25 03:31:50

FLASH的优点~你用眼睛所看到的东西~都能用它来实现~一点不夸张~高楼大厦-花草树木-高山流水-天空白云-阿猫阿狗-一切活的东西都可以容入到FLASH里面
页: [1]
查看完整版本: 来看看:网页FLASH动画克制右键菜单的办法-Flash actionscript