flash as2.0代码详细解释

//AS2.0
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);
};
}
谁能详细解释下上面的FLASH代码吗?
mf是影片剪辑。这些vr,vy,sdy,sdx,sj,mcl是什么属性,或是在软件作品中那里事先设好的啊?

//AS2.0 
var mc = this.createEmptyMovieClip("mc", 0); //创建一个空白mc在层级0
for (var i = 0; i<40; i++) { 
 var mf = mc.attachMovie("mf", "mf"+i, i); //在mc内循环创建40个空白mc,名字为mf0 - mf39
 mf.vr = 0; //mf实例的自定义属性vr 以下类同 vy sdy sdx vx等
  mf.vy = 0;
  mf.sdy = Math.random()/2;
  mf.sdx = Math.random();
  mf.vx = 0;
  random(2) == 0 ? mf.sj=1 : mf.sj=-1; //产生一个随机值 判断是否为0,根据情况赋值mf实例的自定义属性sj为正负1
  mf._x = random(550); //随机设置mf实例的x y 坐标
  mf._y = random(300);
  mf._xscale = mf._yscale=random(70)+20; //随机缩放比例为%20 - %90
  mf.sj<0 && (mf._xscale *= -1); //如果上面设置mf实例的sj属性为-1 则让mf反转一下显示
  mf.mcl = 0.8;
  mf.swapDepths(mf._xscale*1000+i); //设置mf实例的层级分布在 正负1000+(0至39) 这个范围的层级内
  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);
  };
}

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答