Anda di halaman 1dari 14

Tuesday, April 27, 2010

Control suara sederhana dgn Action Script Flash

Bila anda biasa memasukkan suara di flash dengan cara embed di frame, maka sebaiknya anda membaca terus postingan ini. Telah kita rasakan bahwasanya memasukkan suara dengan cara tersebut memiliki banyak kelemahan dan keterbatasannya. Bagaimana bila kita akan melakukan interaksi dengan suara tersebut? Misalnya play, stop, pouse, membesarkan volume dan lain-lain. Semua keterbatasan tersebut dapat diatasi bila kita memasukkan suara mengunakan Action script. Cara memasukkannya atau melakukan loading anda dapat membaca postingan saya sebelumnya. Untuk postingan ini saya hanya akan sharing cara mengatur secara sederhana. Coba perhatikan animasi swf berikut ini : Untuk membuat animasi di atas langkah-langkahnya :

buat 3 button untuk play, stop dan pause posisi button play dan pause sama dengan kondisi button play berada diatas Beri nama instan "continue_btn" (tanpa petik) untuk play. Beri nama instan "pause_btn" (tanpa petik) untuk play. Beri nama instan "stop_btn" (tanpa petik) untuk play. Buat dynamic Text dengan variable "myseek" (tanpa petik). Masukkan mc fader-round yang ada di windows>commond library>button>classic button>knop & feader dan beri nama instant "volumenya" (tanpa petik). Import musik/lagu yang anda inginkan, kemudian di library lagu tersebut di klik kanan lalu pilih linkage kemudian centang export for Action Script dan isikan identifier dengan "lagunya" (tanpa petik). Pasang AS dibawah ini pada frame. posisi = 0; continue_btn._visible = true; pause_btn._visible = false; mySound = new Sound(); mySound.attachSound("lagunya"); pause_btn.onRelease = function() { posisi = Math.floor(mySound.position/1000);

mySound.stop(); continue_btn._visible = true; pause_btn._visible = false; }; continue_btn.onRelease = function() { mySound.start(posisi); continue_btn._visible = false; pause_btn._visible = true; }; stop_btn.onRelease = function() { posisi = 0; mySound.stop(); continue_btn._visible = true; pause_btn._visible = false; }; volumenya.knob.onMouseMove = function() { mySound.setVolume(volumenya.knob._y); }; detik = 0; onEnterFrame = function () { posisinya = Math.floor(mySound.position/1000); menit = Math.floor(posisinya/60); detik = posisinya-(menit*60); if (menit<10) { menitnya = "0"+menit; } else { menitnya = menit; } if (detik<10) { detiknya = "0"+detik; } else { detiknya = detik; } myseek = menitnya+":"+detiknya; };

Flash Sound On/Off Button


On-off button in Flash Actionscripting for Sound/Music files
This Flash tutorial teaches how to play and stop sound/music files using simple actionscript. You Are Here ::: Home >> Free Tutorials >> Flash Tutorials >> Sound On Off Button

Sound on/off Demo

Introduction
While working in Flash with sound/music files you will find it really necessary to use a sound on/off button as an option. We have endeavored to make the action scripting used in this tutorial as basic & minimal as possible. Happy Learning! Please take a look at the demo above. This demo is a simple play/stop button for you to control the sound files in your Flash project. Usually you will need to have the music playing and have a stop button displayed first. Since it is easier to understand how a play and then stop button works we have used this example first. Once this is done we will also teach you how to start with the sound playing and the stop button displayed.

Preparing buttons, importing your sound file and setting the timeline

Create two buttons that are sort of similar and represent sound on and off. For example you can use play/stop or speaker with sound waves/speaker with a cross buttons. Import your sound file into your movie: Press (Ctrl+R) to get the Import screen, now browse to locate your sound file. Open your Library panel (Ctrl+L), locate and right click on your sound file. From the list select Linkage... the linkage properties form will pop-up. In the identifier text box enter mix1 and tick the "Export for Actionscript" and "Export in first frame" options under

Linkage. What this Does: You are giving the sound file in the library an identifier without it actually being used in the movie timeline. This enables it to be called and used by ActionScript code.

In your movie timeline, create 3 consecutive key frames. Place your Play button in the second frame and label it as play and your Stop button in the third frame and label it as stop (The frame label is specified in the properties window). They should both be in the same position for them to look like a switch (see demo).

Making your sound on/off buttons functional using ActionScript


Basic Logic: We are utilizing the inbuilt Sound Class in Flash to dynamically load the sound file and the on/off buttons to play and stop it.

Click the first key frame and copy-paste the following actionscript into the actions panel. my_sound = new Sound(); my_sound.attachSound("mix1"); play(); What this Does: You are creating an instance of the Sound Class whose source is mix1 (the identifier in the library for your sound file).

Click the 2nd and 3rd frames and give the stop() action. Select the play button in the 2nd frame and copy-paste the following actionscript code into the actions panel. on (release) { _root.my_sound.start(0,1000); _root.gotoAndStop("stop"); } What this Does: On clicking your play button, you are telling your sound instance to start playing and the timeline to go and display the stop button in the "stop" frame. The optional parameters (0,1000) for the start function are given for looping of the sound or music file. This specifies that the sound file starts playing at 0 milliseconds and is looped 1000 times (any number value depending on the duration of the sound file and how long you want it to loop).

Select the stop button in the 3rd frame and copy-paste the following actionscript code into the actions panel. on (release) { _root.my_sound.stop();

_root.gotoAndStop("play"); } What this Does: On clicking your stop button, You are telling your sound instance to stop playing and the timeline to go and display the start button in the "play" frame. That's it your sound on/off button is ready! Its that simple. Cool Tip: You can use these buttons even within a movie clip as the sound instance is initiated in the main timeline.

Want to start with the sound playing?


To do this just do the following:

Click the first frame and in the actions panel place the following actionscript code: my_sound.start(0,1000); gotoAndStop("stop"); in place of the last line: play; Your ActionScript for the first frame will look as follows. my_sound = new Sound(); my_sound.attachSound("mix1"); my_sound.start(0,1000); gotoAndStop("stop"); What this Does: You are telling your sound instance to play as soon as it is initiated and the timeline to go and display the stop button in the "stop" frame.

Well Done! You now know how to play and stop sound/music files using simple ActionScripting.

Membuat Tombol On/Off Suara dengan Flash animasi


inShare Tipsntrick.net - tutorial Flash animasi berikut ini akan menjelaskan bagaimana membuat tombol On/Off suara, dimana tombol tersebut berfungsi sebagai kontrol untuk menyalakan dan mematikan suara. Cara berikut ini sangatlah sederhana dan mudah untuk dimengerti, ikuti langkah-langkah berikut ini :

Langkah 1 Buat Dokument baru dengan dimensi 50 px x 50 px

Langkah 2 Buat layer dengan urutan seperti gambar berikut :

Langkah 3 Pada Layer "backg" berikan warna sesuai keinginan anda

Langkah 4 Pada layer "status" Frame 1 buat gambar yang berfungsi sebagai tanda "ada suara",

kemudian ubah ke bentuk symbol-Button, atau pada keyboard tekan F8 , beri nama btn1

Setelah itu pada symbol btn1 ( bukan di layer), tekan dan tambahkan action script sebagai berikut

on (release) { nextFrame(); }

Langkah 5 Pada layer "status" Frame 2 , sama seperti langkah 4, tapi gambar yang dimaksud adalah sebagai tanda "tidak ada suara "

kemudian ubah ke bentuk symbol-Button, atau pada keyboard tekan F8 , beri nama btn2 ,Setelah itu pada symbol btn2 ( bukan di layer), tekan dan tambahkan action script sebagai berikut

on (release) { prevFrame(); }

Langkah 6 Masukkan suara/sound, caranya masuk pada File > Import > Import to stage Setelah itu pada panel properties ( kanan bawah ), ubah dan pilih nama file yang baru saja dimasukkan

untuk membuat suara berulang, pilih Loop

Langkah 7

Pada layer "actionScript" Frame 1, copy this code and insert to frame 1

stop();

Pada layer "actionScript" Frame 2, copy this code and insert to frame 2

stopAllSounds();

Selesai !

Test dengan tekan Ctrl+Enter

Read more about Membuat Tombol On/Off Suara dengan Flash animasi

Membuat scroll bar

Cara pembuatannya, 1. Klik Teks tool, lalu pada Propertis, pilihlah pada bagian tipe teks menjadi Dinamic Teks, dengan perataan Center, Tipe baris menjadi Multiline dan klik tombol Show Border Around Teks.

2. Klik dan seret di stage untuk membuat sebuah area dinamic teks. 3. Dalam area dinamic teks, tulislah teks yang agak panjang agar teks di croll. 4. Klik menu window > Components (ctrl+f7) untuk menampilkan panel component. Seret komponen ScrollBar ke dalam area Dynamic Teks.

5. Tes Movie (ctrl +enter) SELESAI

Membuat Scroll Bar Pada Flash dengan Mudah


Dec 19 Posted by gsmega27 Halo sahabat sahabatku, kali ini saya akan berbagi cara membuat Scroll Bar pada flash dengan sangat mudah. Ikuti langkah berikut ini : 1. Dengan menggunakan Text Tool Buat Text yang agak panjang seperti berikut :

2. Pada panel properties ubah pengaturan menjadi Dynamic Text.

3. Tekan Ctrl + F7 pada keyboard untuk memunculkan kotak dialog berikut :

4. Pada User Interface pilih UIScrollBarkemuadian drag and drop ke stage letakkan di samping text tadi :

5. Setelah Scroll terlihat seperti gambar di atas silakan perpanjang tulisan, sehingga ada yang di scroll. 6. Tekan Ctrl + Enter, maka hasil akan terlihat seperti di bawah ini :

Selamat Mencoba, Semoga Berhasil! :p

Anda mungkin juga menyukai