Saturday, February 26, 2011

code tao bot bien

soLuong = 70;
sW = Stage.width;
sH = Stage.height;
for (var i = 0; i<soLuong; i++) {
_root.createEmptyMovieClip("snow", 0);
snow = _root.attachMovie("sn", "sn"+i, i);
with (snow) {
_x = Math.random()*sW;
_y = Math.random()*sH;
_xscale = _yscale=_alpha=Math.random()*30+70;
}
this["sn"+i].ySpeed = Math.random()*3+0.5;
this["sn"+i].aa = 0;
this["sn"+i].ab = Math.random()*0.05+0.025;
_root["sn"+i].onEnterFrame = function() {
this._y -= this.ySpeed;
this.aa += this.ab;
this._x += Math.sin(this.aa);
if (this._x>sW+5) {
this._x = -5;
} else if (this._x<0) {
this._x = sW+5;
}
if (this._y>sH+5) {
this._y = -5;
} else if (this._y<-5) {
this._y = sH+5;
}
};
}

No comments:

Post a Comment