昨天我发了一个关于鼠标跟随,并且有点弹性,那么今天要做的是一个鼠标跟随的例子。比较花效果:
那么代码就是以下的样子了:
function BOX():MovieClip {
var mc:MovieClip = this.createEmptyMovieClip("boxs", this.getNextHighestDepth());
var w:Number = 10;
var h:Number = 10;
mc.beginFill(0xffffff);
mc.lineTo(w, 0);
mc.lineTo(w, h);
mc.lineTo(0, h);
mc.lineTo(0, 0);
mc.endFill();
return mc;
}
var boxs:MovieClip = BOX();
var myarray=new Array(0xFFFFFF,0xFF0000,0xFF9900,0xFFFF00,0x00FF00,0x339999,0x0000FF,0x9900FF,0x000000,0xFFFFFF)
function gensui(mcs, n) {
for (var i = 0; i<n; i++) {
var MCs:MovieClip = boxs.duplicateMovieClip(mcs+i, n-i);
var mycolor=new Color(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);
直接复制粘贴到帧上就可以了。因为不难理解,所以没有给予注释。如果有什么地方不懂请提出来。我讲给予回答。这里感谢“流水无情”,“clamp444"两位朋友的帮忙。谢谢你们给予我很多的帮助。