|
Webjx核心提示:Flash实例教程:鼠标点击出现图片动画.
本文是适合初学者的FLASH教程,最终效果是用鼠标点击后,一个图片出现,从左上角到右下角放大显示,先来看最终效果:
效果如上,鼠标点击动画就会出现一个图片
下面开始讲述制作步骤:
第一步:首先准备一幅图片:

然后打开FLASH,之后新建立一个文档:

然后把图片导入到FLASH中,把图片转换为影片剪辑:

然后按Ctrl+L打开库,找到这个影片剪辑,然后右击:

设置如下:

回到舞台后,把图片影片剪辑删除掉,选择第一帧,添加如下动作:
function Main() {
stage.addEventListener(MouseEvent.CLICK, AddImage);
}
Main();
function AddImage(e:MouseEvent):void {
var newImage:CoolImage = new CoolImage();
this.addChild(newImage);
newImage.x = mouseX;
newImage.y = mouseY;
newImage.scaleX = 0;
newImage.scaleY = 0;
newImage.alpha = 0;
newImage.addEventListener(Event.ENTER_FRAME, ZoomImage);
}
function ZoomImage(e:Event):void {
var imageMC:MovieClip = MovieClip(e.target);
imageMC.scaleX += .05;
imageMC.scaleY += .05;
if (imageMC.scaleX < 4) {
imageMC.alpha += .05;
} else {
imageMC.alpha -= .05;
if (imageMC.alpha < .8) {
imageMC.removeEventListener(Event.ENTER_FRAME, ZoomImage);
}
}
}
最终效果如上,希望大家喜欢。 |
|
【收藏】【打印】【进入论坛】 |
|
|
|
|
|
|
|