import fl.transitions.TweenEvent;//导入缓动事件
import fl.transitions.easing.Regular;//导入缓动效果中有规律的
var arrTupian:Array=[];//存放图片的数组
var tweenscaleX:Tween;//用来控制图片宽高的缓动类
var tweenscaleY:Tween;
var datu:MovieClip;
for (var i:int=0; i<8; i++) {
var xiaotu:MovieClip =new Pic();//这里Pic是库中一个存放图片的类文件
addChild(xiaotu);
xiaotu.gotoAndStop(i+1);
xiaotu.width=120;
xiaotu.height=100;
xiaotu.x=xiaotu.width/2+i*(xiaotu.width+10);
xiaotu.y=420;
arrTupian.push(xiaotu);
xiaotu.addEventListener(Event.ENTER_FRAME ,dongf);//为每个小球添加移动帧频函数
}
function dongf(e) {
var mc:MovieClip=e.target;
mc.x-=6;
if (mc.x<0-(xiaotu.width/2+10)) {//如果该图片出了场景则放在最后一张图片的位置
mc.x=xiaotu.width/2+7*(xiaotu.width+10);
}
mc.buttonMode=true;
mc.addEventListener(MouseEvent.MOUSE_OVER ,overf);///鼠标移过时候停止移动
mc.addEventListener(MouseEvent.MOUSE_OUT,outf);//
}
function overf(e) {
for (i=0; i
arrTupian[i].removeEventListener(Event.ENTER_FRAME ,dongf);
arrTupian[i].removeEventListener(MouseEvent.MOUSE_OVER ,overf);
//注意也要把移过函数移除,等下次再调用再添加防止下面的效果还没有达到又开始此函数
}
//此时大图出现
datu=new Pic();
datu.gotoAndStop(arrTupian.indexOf (e.target)+1);
addChild(datu);
datu.x=stage.stageWidth/2;
datu.y=200;
tweenscaleX=new Tween(datu,"scaleX",Regular.easeOut,1,3,0.5,true);//参数从1倍扩大到3倍
tweenscaleY=new Tween(datu,"scaleY",Regular.easeOut,1,3,0.5,true);
//参数分别是对象,属性,缓动类型,开始参数,结束参数,缓动事件,true表示为单位为妙false表示为帧
}
function outf(e) {
e.target.removeEventListener(MouseEvent.MOUSE_OVER ,overf);
e.target.removeEventListener(MouseEvent.MOUSE_OVER ,outf);
tweenscaleX=new Tween(datu,"scaleX",Regular.easeOut,3,1,0.5,true);//开始和结束的参数反过来则实现了缩小的效果
tweenscaleY=new Tween(datu,"scaleY",Regular.easeOut,3,1,0.5,true);
//tweenScaleX=new Tween.yoyo ()或者用这个方法,表示实现原来缓动的相反过程
//tweenScaleY=new Tween.yoyo ()
tweenscaleX.addEventListener(TweenEvent.MOTION_FINISH,fishf);
}
function fishf(e) {
removeChild(datu);
datu=null;//注意从显示列表中清除后,
//元件本身还有东西,因此还要把大图元件清空
for (i=0; i
}