[原创]液滴效果
首次见到这个效果是在《小小作品9》上,今天终于仿制成功,特贴出来与大家分享。:) [font=Times New Roman]源代码[code]Stage.scaleMode = "noScale";_root.attachMovie("LineGroup", "lg_mc", -2);
_root.attachMovie("Ball", "ball_mc", -1);
for (var i = 0; i<6; i++) {
_root.attachMovie("ChangeLine", "cl"+i+"_mc", i);
_root["cl"+i+"_mc"]._yscale=98
}
var k:Number = 0.1;
var r:Number = ball_mc._width/2;
var w:Number = Stage.width;
var h:Number = Stage.height;
lg_mc._x = w/2;
lg_mc._y = h/2;
_root.onEnterFrame = function() {
var gx:Number = _root._xmouse;
var gy:Number = _root._ymouse;
var lx:Number = ball_mc._x;
var ly:Number = ball_mc._y;
gx = gx<r ? r : gx;
gx = gx>(w-r) ? (w-r) : gx;
gy = gy<r ? r : gy;
gy = gy>(h-r) ? (h-r) : gy;
var nx = Math.floor((lx-15)/30);
var ny = Math.floor((ly-15)/30);
with (cl0_mc) {
_x = nx*30;
_y = ly;
_rotation = 180;
var d = Math.floor(Math.abs(lx-_x));
cl0_mc.gotoAndStop(d);
}
with (cl1_mc) {
_x = nx*30+30;
_y = ly;
var d = Math.floor(lx-_x);
if (d>0) {
_rotation = 180;
} else {
_rotation = 0;
}
d = Math.abs(d);
d = d == 0 ? 1 : d;
cl1_mc.gotoAndStop(d);
}
with (cl2_mc) {
_x = nx*30+60;
_y = ly;
_rotation = 0;
var d = Math.floor(Math.abs(lx-_x));
cl2_mc.gotoAndStop(d);
}
with (cl3_mc) {
_x = lx;
_y = ny*30;
_rotation = 270;
var d = Math.floor(Math.abs(ly-_y));
cl3_mc.gotoAndStop(d);
}
with (cl4_mc) {
_x = lx;
_y = ny*30+30;
var d = Math.floor(ly-_y);
if (d>0) {
_rotation = 270;
} else {
_rotation = 90;
}
d = Math.abs(d);
d = d == 0 ? 1 : d;
cl4_mc.gotoAndStop(d);
}
with (cl5_mc) {
_x = lx;
_y = ny*30+60;
_rotation = 90;
var d = Math.floor(Math.abs(ly-_y));
cl5_mc.gotoAndStop(d);
}
ball_mc._x += (gx-lx)*k;
ball_mc._y += (gy-ly)*k;
};[/code][/font] 下载包:
Flash影音文件*1,IE播放文件*1(用于那些无法正常播放swf文件的用户)
页:
[1]