B2: Tạo 1 movieClip có 1 vòng tròn
B2: Tạo linkage cho movieClip đó
Đặt linkage là “sn”
B3: Viết code sau lên frame
Code:
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;
}
};
}
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;
}
};
}
B4: Ctrl + Enter để test thử!
No comments:
Post a Comment