Effect Demo:
Click here to download the source file
First create a few buttons, put in the first frame, click on the button on the button to write the following code:
On (release) {
Create a function so that the music file is loaded to 25% before it starts playing, otherwise it will be loaded from the Web when the card.
function Zairu () {
if (b>=25) {
Mysound.start (0,10);
Clear if loaded to 25%.
Clearinterval (poll);
}
}
Poll=setinterval (zairu,100);
Yinyue ("You want to load the MP3 address");
}
Back to the main scene, create 2 dynamic text, the variable name is TXT1,TXT2,TXT3,
function Yinyue (name) {
Establish sound objects for easy control of sound
Mysound=new Sound (this);
Load Sound
Mysound.loadsound (name,true);
Stop the sound first, or the sound will be loaded to play automatically when you start the decompression program.
Mysound.stop (name);
}
function loading () {
Loaded sound size
L=mysound.getbytesloaded ();
Total Sound Size
M=mysound.getbytestotal ();
B=int (l/m*100);
txt1=b+ "%";
Txt2=int (l/1000)/1000+ "M" + "/" +int (m/1000)/1000+ "M";
Played sound time
Time=int (mysound.position/1000);
Total sound Time
Time2=int (mysound.duration/1000);
S1=time;
if (s1<10) {
s1= "0" +S1;
}
Txt3= "Played:" +s1+ "seconds";
Loading21.loading3._xscale=b;
Set the volume size of the sound,
Mysound.setvolume ((huakuai2.huakuai._x+50) *2);
}
Timer trigger time is 100 milliseconds, so the variables set above are constantly updated
SetInterval (loading,100);
Create playback, pause, fast-forward, rewind button write as
On (release) {
This.mysound.start (this.mysound.position/1000,1);
}
On (release) {This.mysound.stop ();}
On (release) {
This.mysound.start ((this.mysound.position/1000) +10,1);
}
On (release) {
This.mysound.start ((this.mysound.position/1000) -10,1);
}