PMK is A noBAD Friend

Tạo bọt biển bằng Flash

Làm xong bong bóng nó sẽ nổi lên ùng ục:

B1: Mở 1 file mới kích thước tuỳ, background color #0099FF
B2: Tạo 1 movieClip có 1 vòng tròn

B3: Tạo linkage cho movieClip đó

Đặt linkage là “sn”

B4: 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;
}
};
}

——————————————————————–

B5: Ctrl + Enter để test thử!

Theo onvn

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s