昨天我发了一个关于鼠标跟随,并且有点弹性,那么今天要做的是一个鼠标跟随的例子。比较花
效果:
那么代码就是以下的样子了:
functionBOX():MovieClip{
varmc:MovieClip=this.createEmptyMovieClip("boxs",this.getNextHighestDepth());
varw:Number=10;
varh:Number=10;
mc.beginFill(0xffffff);
mc.lineTo(w,0);
mc.lineTo(w,h);
mc.lineTo(0,h);
mc.lineTo(0,0);
mc.endFill();
returnmc;
}
varboxs:MovieClip=BOX();
varmyarray=newArray(0xFFFFFF,0xFF0000,0xFF9900,0xFFFF00,0x00FF00,0x339999,0x0000FF,0x9900FF,0x000000,0xFFFFFF)
functiongensui(mcs,n){
for(vari=0;i
varMCs:MovieClip=boxs.duplicateMovieClip(mcs+i,n-i);
varmycolor=newColor(MCs)
mycolor.setRGB(myarray[i])
MCs._alpha=n*n-i*n
MCs.i=i-1;
MCs.onEnterFrame=function(){
eval(mcs+0)._x=_xmouse;
eval(mcs+0)._y=_ymouse;
eval(mcs+0)._visible=false;
this._x+=(eval(mcs+this.i)._x-this._x)*0.5+this._width;
this._y+=(eval(mcs+this.i)._y-this._y)*0.5;
};
}
}
gensui("boxs",10);
直接复制粘贴到帧上就可以了。因为不难理解,所以没有给予注释。