MEMBUAT ANIMASI BOUNCING BALL
Sebenarnya tidak ada yang keren, hanya menambahkan sedikit script saja pada flash.
Okeh hayo kita mulai,,,
1. aktifkan flash buat sebuah dokumen baru….
2. klik frame 1, layer 1 tampilkan panel ActionScript dengan menekan F9.
3. tambahkan scrip berikut:
function fall( ) {
// Add acceleration due to gravity
// Menambah kecepatan seiring
this.speedY += GRAVITY;
this.speedY *= FRICTION;
this._y += this.speedY;
// movie clip “melompat” ke atas ketika jatuh ke lantai (garis batas)
if (this._y > 400) {
this._y = 400;
this.speedY = -this.speedY * ELASTICITY;
}
}
// Fungsi untuk men-drag movie clip bola
function drag( ) {
// Ketika movie clip bola di klik, buat agar dapat di drag
// dan berhenti menganimasikannya via onEnterFrame
this.startDrag( );
delete this.onEnterFrame;
this.onMouseMove = function( ) {
updateAfterEvent( );
};
}
// Fungsi menjatuhkan movie clip
function drop( ) {
this.speed.y = 0;
this.stopDrag( );
this.onEnterFrame = fall;
}
// KODE UTAMA
// Membuat dua puluh movie clip bola
for (var i = 0; i < 20; i++) {
var ball:MovieClip = this.createEmptyMovieClip(“ball” + i, i);
ball.lineStyle(6, 0x0, 100);
ball.moveTo(0, -3);
ball.lineTo(1, -3);
ball._x = Math.random( ) * 550;
ball._y = Math.random( ) * 200;
ball.speedY = 0;
ball.onEnterFrame = fall;
ball.onPress = drag;
ball.onRelease = ball.onReleaseOutside = drop;
}
// Inisialisasi nilai konstanta variabel
var GRAVITY:Number = 0.5;
var FRICTION:Number = 0.995;
var ELASTICITY:Number = 0.85;
// Menggambar garis batas
this.lineStyle(0, 0xDDDDDD, 100);
this.moveTo(0, 400);
this.lineTo(550, 400);
4. Tekan Ctrl+J untuk menampilkan panel Propertis, masukan nilai Frame rate : 32 lalu tekan OK, semakin tinggi nilai Frame Rate , animasinya akan semakin halus..
5.selesai. :)
Sumber https://flashpermanen.wordpress.com/e-trik/apa-macromedia-flash/trik-flash-animasi-bouncing-balls/
0 komentar:
Posting Komentar