|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
不是MX版本升级到MX2004时的那么简单,而是实现了新的飞跃。
本例先容使用Flash的AS3代码完成滤镜动画效果的制造,译者具体注释了代码的使用,喜好本效果的伴侣能够下手尝尝~~
效果演示:(请用鼠标在画面上点击寓目效果)
在这个教程中,我们将增加含混和斜角滤镜给图片,一切的动画都是用Actionscript3.0制造,在图片上挪动你的鼠标看看效果。当你把握了这些你将一样能创立另外一些滤镜效果,好吧,翻开你的flash我们入手下手吧。
设置情况:
1.创立一个新的文档,巨细为500x250。
2.导进两张图片到舞台(约莫200x200),你能够象我一样导进一张方的和一张园的图片。
3.将两张图片转换为MC,你能够这它们取上你喜好的名字;将注册点移到中央。
4.给它们取上实例称号分离为:“apple01”和“apple02”。
进进AS3翻开你的举措面板输出上面的代码:
//利用动画滤镜
varblurSpeed:Number=1;
varbevelSpeed:Number=5;
//为两个苹果增加MOUSE_OVER事务侦听
appleapple01.addEventListener(MouseEvent.MOUSE_OVER,mouseOverApple01);
apple02.addEventListener(MouseEvent.MOUSE_OVER,mouseOverApple02);
//这两个苹果增加MOUSE_OUT事务侦听
appleapple01.addEventListener(MouseEvent.MOUSE_OUT,mouseOutApple01);
apple02.addEventListener(MouseEvent.MOUSE_OUT,mouseOutApple02);
/*为两个苹果增加ENTER_FRAME,如许我们就可以每隔一帧的工夫绘制它们*/
apple01.addEventListener(Event.ENTER_FRAME,enterFrameApple01);
apple02.addEventListener(Event.ENTER_FRAME,enterFrameApple02);
//创立并附加含混滤镜给apple01
varblur:BlurFilter=newBlurFilter();
blur.blurX=20;
blur.blurY=20;
blur.quality=BitmapFilterQuality.HIGH;
apple01.filters=[blur];
//创立一个斜角滤镜给apple02
varbevelFilter:BevelFilter=newBevelFilter(10,45,0x000000,1,0xffffff,1,0,0,0,BitmapFilterQuality.HIGH,BitmapFilterType.INNER,false);
apple02.filters=[bevelFilter];
//设置省缺值(鼠标没挪动到苹果上时)
varmouseIsOverApple01:Boolean=false;
varmouseIsOverApple02:Boolean=false;
//当鼠标移到apple01上时挪用
functionmouseOverApple01(event:MouseEvent):void{
mouseIsOverApple01=true;
}
//当鼠标移到apple02上时挪用
functionmouseOverApple02(event:MouseEvent):void{
mouseIsOverApple02=true;
}
//当鼠标移出apple01时挪用
functionmouseOutApple01(event:MouseEvent):void{
mouseIsOverApple01=false;
}
//当鼠标移出apple02时挪用
functionmouseOutApple02(event:MouseEvent):void{
mouseIsOverApple02=false;
}
//这个函数绘制apple01的动画
functionenterFrameApple01(event:Event):void{
//假如鼠标在苹果上挪动削减含混
if(mouseIsOverApple01==true){
blur.blurX-=blurSpeed;
blur.blurY-=blurSpeed;
}
/*假如鼠标移出苹果,而且含混没凌驾20,我们增添含混。*/
if(mouseIsOverApple01==false&&blur.blurX<=20){
blur.blurX+=blurSpeed;
blur.blurY+=blurSpeed;
}
/*在改动含混滤镜后我必要从头分派滤镜*/
apple01.filters=[blur];
}
//这个函数绘制apple02的动画
functionenterFrameApple02(event:Event):void{
//假如鼠标移到这个苹果上,我们增添含混滤镜直到100
if(mouseIsOverApple02==true&&bevelFilter.blurX<100){
bevelFilter.blurX+=bevelSpeed;
bevelFilter.blurY+=bevelSpeed;
//我们必要分派一个力度给斜角让它可见
bevelFilter.strength=5;
}
//假如鼠标移出apple02,削减含混
if(mouseIsOverApple02==false){
bevelFilter.blurX-=bevelSpeed;
bevelFilter.blurY-=bevelSpeed;
}
/*假如我们断定含混滤镜正被利用,我们让全部斜角不成见。(strengthis0).不然我们会看到一些丢脸的曲线。*/
if(bevelFilter.blurX==0){
bevelFilter.strength=0;
}
/*当我们改动了斜角滤镜时,我们必要从头分派一次滤镜*/
apple02.filters=[bevelFilter];
}
已完了!测试影片,假如你有甚么成绩,请会见论坛!上面附代码供研讨。
varblurSpeed:Number=1;
varbevelSpeed:Number=5;
appleapple01.addEventListener(MouseEvent.MOUSE_OVER,mouseOverApple01);
apple02.addEventListener(MouseEvent.MOUSE_OVER,mouseOverApple02);
appleapple01.addEventListener(MouseEvent.MOUSE_OUT,mouseOutApple01);
apple02.addEventListener(MouseEvent.MOUSE_OUT,mouseOutApple02);
apple01.addEventListener(Event.ENTER_FRAME,enterFrameApple01);
apple02.addEventListener(Event.ENTER_FRAME,enterFrameApple02);
varblur:BlurFilter=newBlurFilter();
blur.blurX=20;
blur.blurY=20;
blur.quality=BitmapFilterQuality.HIGH;
apple01.filters=[blur];
varbevelFilter:BevelFilter=newBevelFilter(10,45,0x000000,1,0xffffff,1,0,0,0,BitmapFilterQuality.HIGH,BitmapFilterType.INNER,false);
apple02.filters=[bevelFilter];
varmouseIsOverApple01:Boolean=false;
varmouseIsOverApple02:Boolean=false;
functionmouseOverApple01(event:MouseEvent):void{
mouseIsOverApple01=true;
}
functionmouseOverApple02(event:MouseEvent):void{
mouseIsOverApple02=true;
}
functionmouseOutApple01(event:MouseEvent):void{
mouseIsOverApple01=false;
}
functionmouseOutApple02(event:MouseEvent):void{
mouseIsOverApple02=false;
}
functionenterFrameApple01(event:Event):void{
if(mouseIsOverApple01==true){
blur.blurX-=blurSpeed;
blur.blurY-=blurSpeed;
}
if(mouseIsOverApple01==false&&blur.blurX<=20){
blur.blurX+=blurSpeed;
blur.blurY+=blurSpeed;
}
apple01.filters=[blur];
}
functionenterFrameApple02(event:Event):void{
if(mouseIsOverApple02==true&&bevelFilter.blurX<100){
bevelFilter.blurX+=bevelSpeed;
bevelFilter.blurY+=bevelSpeed;
bevelFilter.strength=5;
}
if(mouseIsOverApple02==false){
bevelFilter.blurX-=bevelSpeed;
bevelFilter.blurY-=bevelSpeed;
}
if(bevelFilter.blurX==0){
bevelFilter.strength=0;
}
apple02.filters=[bevelFilter];
}
Macromedia公司已经承诺在Flash8中将有很大的变化,而且它们中的许多都与视频功能有关。 |
|