艺虎动画 > AS2.0 打造蜜蜂飞舞效果

AS2.0 打造蜜蜂飞舞效果

翼虎动漫   2010-7-23

 

 

AS2.0 打造蜜蜂飞舞效果:

http://img.flashzhizuo.net.cn/us/201072394159374.swf

 

详细代码:

//AS2.0  QQ:31559783    2010-06-08

var mc = this.createEmptyMovieClip("mc", 0);

for (var i = 0; i<40; i++) {

var mf = mc.attachMovie("mf", "mf"+i, i);

mf.vr = 0;

mf.vy = 0;

mf.sdy = Math.random()/2;

mf.sdx = Math.random();

mf.vx = 0;

random(2) == 0 ? mf.sj=1 : mf.sj=-1;

mf._x = random(550);

mf._y = random(300);

mf._xscale = mf._yscale=random(70)+20;

mf.sj<0 && (mf._xscale *= -1);

mf.mcl = 0.8;

mf.swapDepths(mf._xscale*1000+i);

mf.onEnterFrame = function() {

  this.vr += 0.03;

  this._y += Math.cos(this.vr)*this.vy*this.sj;

  this._x -= this.vx*this.sj;

  this.vy *= this.mcl;

  this.vx *= this.mcl;

  this.vy += this.sdy;

  this.vx += this.sdx;

  var ID = Math.random()*30 >> 0;

  ID == 1 && (this.mcl=0.9);

  ID == 2 && (this.mcl=0.7);

  ID == 3 && (this.mcl=0.5);

  ID == 4 && (this.yj.play());

  this._x<0 && (this._x=550);

  this._x>550 && (this._x=0);

};

}

源文件下载:勤劳的蜜蜂.rar