下面是雪花飘落的程序(FLASH AS2.0程序)
var i=1;
snow._x=-100;
onEnterFrame=function() {
duplicateMovieClip("snow", "snow" + i, i);
this["snow"+i]._x=random(Stage.width);
this["snow"+i]._y=-3;
this["snow"+i]._alpha=60+random(50);
this["snow"+i]._xscale=random(5)+16;
this["snow"+i]._yscale=random(5)+16;
this["snow"+i].speed=random(3)+2;
this["snow"+i]._rotation=random(360);
this["snow"+i].onEnterFrame=function() {
if(this._y<600) {
this._x+=(Math.sin(this._y/19)*1.3);
this._y+=this.speed;
} else{
//超出舞台,则回收再利用
delete this.onEnterFrame;
}
}
我的问题是:把this["snow"+i].onEnterFrame=function() {
if(this._y<600) {
this._x+=(Math.sin(this._y/19)*1.3);
this._y+=this.speed;
} 这部分代码调整成下面的代码不可以,为什么?
this["snow"+i].onEnterFrame=function() {
if(this["snow"+i]._y<600) {
["snow"+i]._x+=(Math.sin(this["snow"+i]._y/19)*1.3);
this["snow"+i]._y+=this["snow"+i].speed;
}