[color=red][color=red][center][color=red]PUT ALL CODES STRAIGHT AFTER EACH OTHER ON THE MAIN FRAME IN THE ORDER THEY ARE POSTED[/color][/center]
[/color][color=green]OK, first up we need some movie clips.[/color]**
[color=black]Place in a movie clip (MC) with the instance name “volume” of a line with a width of 250 exactly, do it with the properties tab. [/color]
[color=black]Once you have done that double click it. Inside this MC lock the layer with the line on it, and lock it. Create a new layer, and on that put in a picture of a slider, and giv[/color][color=black]e it the INSTANCE NAME, “knob_mc”.[/color]
[color=#000000]Now, make another image, which will be easy for users to click on, make the the width of this, 250 exactly also. Instance name it mask.[/color]
[color=black]Now, create your buttons. Name the buttons for the songs respectively, song1, song2, etc…[/color]
[color=black]Also make an image of a speaker, with no sound wave coming out of it. Make it an MC, then, inside this movie clip i[/color][color=#000000]nsert 4 keyframes of the speaker, each with one more sound wave than the other, starting with no waves. Put stop on each frame, in the actions.[/color]
[color=#000000]Then on the last frame, frame 5, make the mute image, also put stop on the layer.[/color]
[color=black]Place in a movie clip with the instance name “slider_mc” of a line with a width of 200 exactly, do it with the properties tab. [/color]
[color=black]Once you have done that double click it. Inside this MC lock the layer with the line on it, and lock it. Create a new layer, and on that put in a picture of a slider, and giv[/color][color=black]e it the INSTANCE NAME, “knob_btn”.[/color]
[color=#000000]Now, make another image, which will be easy for users to click on, make the the width of this, 200 exactly also. Instance name it mask.[/color]
[color=#000000]Then insert a picture of speakers, width of 100 exactly, instance name of speaker. Then inside that, create an image to show the amount of balance to one side. With a width of 50, instance name of balance.[/color]
Others;
[color=black]Play button, instance name “playbut”, 2 keyframes, frame 1 play image, frame 2 pause image.[/color]
[color=#000000]Stop button, instance name “stopbut”.[/color]
[color=#000000]Next button, instance name “next”.[/color]
[color=#000000]Repeat button, instance name “repeatbut”.[/color]
[color=#000000]Previous button, instance name “previous”.[/color]
[color=#000000]Progress bar, intstance name pb, inside it, a dynamic text box with a variable “pos_txt”. On a new layer the bar image, instance name “bar_mc”. Mask this(Make a new layer, insert an MC the same size as the bar, and put it on top of the bar, on the new layer. Right-Click the new layer, and click “Mask”).[/color]
[color=red]Time for some Dynamic text boxes[/color]
[color=#000000]Put in some dynamic text boxes named;[/color]
[color=#000000]“repeat” - will display if repeat is on or off[/color]
[color=#000000]“my_fmt” - will display the current volume[/color]
[color=#000000]“pan” - will display the pan[/color]
[color=#000000]“voltxt” - will display the volume status, normal, blasting etc…[/color]
[color=#000000]“status” - will display song status. Paused, playing etc…[/color]
[color=#000000]“choice” - will display the song, it will be named by the linkage name given[/color]
[color=#000000]“cminutes” - will display current amount of minutes played[/color]
[color=#000000]“cseconds” - will display current amount of seconds played[/color]
[color=#000000]“minutes” - will display total amount of minutes[/color]
[color=#000000]“seconds” - will display total amount of seconds[/color]
[color=red]Step 1;[/color] [color=black](Importing sounds)[/color]
[color=black]First up you need to insert sounds into your library, File>Import>Import to Library.[/color]
[color=#000000]Once you have done that give the Linkage Names, which should be named the same as the song for your convenience. To do this open your library (CTRL + L), and find your sound. Right-Click on the sound and go to Linkage.[/color]
[color=#000000]A small prompt should appear. In this prompt check the box next to Export for Actionscript.[/color]
[color=black]After that, in the Identifier field place the songs name. This is what will be used to call on the song later in your script. Repeat this for each song.[/color]
[/color]****[color=red]Step 2;[/color] (Setting the states of variables)**
This part of the code is used to set the intitial state of all the variables.
It will set;
whether repeat is off or on.
choice, the variable which sets which song to play.
playing to false.
////
//Setting States//
//
repeat = "**[color=red]off[/color]**"; ///Set **repeat** **[color=red]off[/color]**
_root.choice = "**[color=red]Song 1[/color]**"; ///Set the player to play the song with the **linkage name Song 1**
playing = [color=red]**false**[/color]; //Set **playing to** [color=red]**false**[/color]
[color=#ff0000]Step 3;[/color] (Variables)
This section will just set variables for various things. You shouldn’t need to edit any of this at all.
////
//Variables//
//
var my_interval:Number; ///Recognise my_interval as number
var my_sound:Sound = new Sound(); ///Recognise my_sound as a sound
my_sound.onLoad = function(success:Boolean) { ///On load of my_sound,succes
if (success) { ///If successful
trace("sound loaded"); ///Trace that the sound is loaded
}
};
[color=#ff0000]Step 4;[/color] (Buttons)
This is used to tell the Previous, Next, and repeat buttons what to do;
////
//Buttons//
//
_root.next.onRelease = function() { ///On release of the NEXT button
if (_root.choice == "Song 1") { ///If it is currently Song 1
my_sound.stop(); ///Stop the current sound
_root.cseconds = 0; ///cseconds = 0
_root.cminutes = 0; ///cminutes = 0
_root.choice = "Song 2"; ///choice goes to song 2
_root.status = "stopped"; ///Song status equals stopped
_root.playbut.gotoAndStop(1); ///Play button got to the stopped frame
playing = false; ///Playing is false
myMusicPosition = 0; ///My music position is 0
} else if (_root.choice == "Song 2") { ///Else if it is currently Song 2
my_sound.stop();
_root.cseconds = 0;
_root.cminutes = 0;
_root.choice = "Song 1";
_root.status = "stopped";
_root.playbut.gotoAndStop(1);
playing = false;
myMusicPosition = 0;
}
};
_root.previous.onRelease = function() {
if (_root.choice == "Song 2") {
my_sound.stop();
_root.cseconds = 0;
_root.cminutes = 0;
_root.choice = "Song 1";
_root.status = "stopped";
_root.playbut.gotoAndStop(1);
playing = false;
myMusicPosition = 0;
} else if (_root.choice == "Song 1") {
my_sound.stop();
_root.cseconds = 0;
_root.cminutes = 0;
_root.choice = "Song 2";
_root.status = "stopped";
_root.playbut.gotoAndStop(1);
playing = false;
myMusicPosition = 0;
}
};
To edit this you would change this;
if (_root.choice == "Song 1") { ///If it is currently Song 1
my_sound.stop(); ///Stop the current sound
_root.cseconds = 0; ///cseconds = 0
_root.cminutes = 0; ///cminutes = 0
_root.choice = "Song 2"; ///choice goes to song 2
_root.status = "stopped"; ///Song status equals stopped
_root.playbut.gotoAndStop(1); ///Play button got to the stopped frame
playing = false; ///Playing is false
myMusicPosition = 0; ///My music position is 0
} else if (_root.choice == "Song 2") { ///Else if it is currently Song 2
my_sound.stop();
_root.cseconds = 0;
_root.cminutes = 0;
_root.choice = "**Song 2**";
_root.status = "stopped";
_root.playbut.gotoAndStop(1);
playing = false;
myMusicPosition = 0;
} else if (_root.choice == "**Song 3**") { ///Else if it is currently Song 2
my_sound.stop();
_root.cseconds = 0;
_root.cminutes = 0;
_root.choice = "Song 1";
_root.status = "stopped";
_root.playbut.gotoAndStop(1);
playing = false;
myMusicPosition = 0;
}
};
[color=red]Step 5;[/color] (Song Settings)
Ok, now we get into the play buttons…
////
//Song Settings//
//
_root.song1.onRelease = function() { ///Song1(button) on release
_root.choice = "Song 1"; ///choice is Song 1
my_sound.stop();
_root.cseconds = 0;
_root.cminutes = 0;
_root.status = "stopped";
_root.playbut.gotoAndStop(1);
playing = false;
myMusicPosition = 0;
};
_root.song2.onRelease = function() {
my_sound.stop();
_root.cseconds = 0;
_root.cminutes = 0;
_root.choice = "The Simpsons";
_root.status = "stopped";
_root.playbut.gotoAndStop(1);
playing = false;
myMusicPosition = 0;
};
_root.song3.onRelease = function() {
my_sound.stop();
_root.cseconds = 0;
_root.cminutes = 0;
_root.choice = "Puff The Magic Dragon";
_root.status = "stopped";
_root.playbut.gotoAndStop(1);
playing = false;
myMusicPosition = 0;
};
_root.playbut.onRelease = function() { ///Play button on release
if (!playing) { ///If playing equals false
my_sound.start(**[color=red]myMusicPosition[/color]**); ///Start my sound at **myMusicPosition**
playing = true; ///Playing equals true
this.gotoAndStop(2); ///Display pause button
_root.status = "playing"; ///Song status is playing
} else { ///Other wiise
playing = false;
myMusicPosition = my_sound.position/1000; ///myMusicPosition is the current position of the sound
my_sound.stop();///Stop any sounds
this.gotoAndStop(1);
playing = false;
_root.status = "paused"; ///Song status is paused
}
};
_root.stopbut.onRelease = function() {
my_sound.stop();
_root.status = "stopped";
_root.playbut.gotoAndStop(1);
playing = false;
myMusicPosition = 0;
totalSeconds = my_sound.duration/1000;
_root.minutes = Math.floor(totalSeconds/60);
_root.seconds = Math.floor(totalSeconds)%60;
};
_root.repeatbut.onRelease = function() {
if (repeat == "off") {
repeat = "on";
} else if (repeat == "on") {
repeat = "off";
}
};
[color=red]Step 6;[/color][color=black] (Other Stuff)[/color]
This is other stuff, like when the song finished, intervals, etc;
////
//Other//
//
my_sound.onSoundComplete = function() { ///On the completion of my sound
if (repeat == "on") { ///if repeat is on
myMusicPosition = 0;
my_sound.start(myMusicPosition); ///loop
playing = true;
this.gotoAndStop(2);
_root.status = "playing";
} else {
myMusicPosition = 0;
_root.cseconds = 0;
_root.cminutes = 0;
the_sound.position = 0;
_root.playbut.gotoAndStop(1);
my_interval = setInterval(updateProgressBar, 100, my_sound); ///Reset my_interval
playing = false;
_root.status = "Finished..."; ///Status is finished
}
};
//DO NOT EDIT//
my_interval = setInterval(**updateProgressBar**, 100, my_sound); ///Set my_interval
function **updateProgressBar**(the_sound:Sound):Void { ///Update progress bar is the funtion
var pos:Number = Math.round(the_sound.position/the_sound.duration*100); //. Set pos to the_sound position divided by the duration times 100, and round
_root.pb.bar_mc._xscale = pos; ///Set the bars x scale to pos
_root.pb.pos_txt = pos+"%";
}
[color=red]Step 7;[/color] (Volume)
Here is the volume part…
////
//Volume//
//
_root.volume.knob_mc.onEnterFrame = function() {
////
//Display part//
//
my_sound.attachSound(_root.**choice**, true); ///HERE is where the song is set to the variable **CHOICE**
ctotalSeconds = my_sound.duration/1000;
_root.cseconds = Math.floor((ctotalSeconds-my_sound.position*-1)/1000)%60;
_root.cminutes = Math.floor(((ctotalSeconds-my_sound.position*-1)/1000)/60);
totalSeconds = my_sound.duration/1000;
_root.seconds = Math.floor(totalSeconds)%60;
_root.minutes = Math.floor(totalSeconds/60);
if (_root.seconds<10) {
_root.seconds = "0"+_root.seconds;
}
if (_root.cseconds<10) {
_root.cseconds = "0"+_root.cseconds;
}
////
//Volume//
//
_root.my_fmt = my_sound.getVolume()+"%"; ///my_fmt is set the to volume with a % on the end
_root.my_fmt._x = this._x+20;
my_sound.setVolume(this._x); ///Set the volume of my_sound to the _x of the knob_mc instance in the volume MC
if (Key.isDown(Key.RIGHT)) { ///if right button is down, increase the volume by the volupspeed variable.
this._x += volupspeed;
}
if (this._x>=250) { ///if the knob_mc's x is greater than or equal to 250
volupspeed = 0; ///volupspeed equals 0
} else {
volupspeed = 1; ///volupspeed equals 1
}
if (Key.isDown(Key.LEFT)) { ///if left button is down, decrease the volume
this._x -= voldownspeed;
}
if (this._x<=0) { ///if the x is smaller than or equal to 0
voldownspeed = 0;
} else {
voldownspeed = 1;
}
};
_root.volume.mask.onRelease = function() { ///On release of the mask inside the colume image
_root.volume.knob_mc._x = _xmouse;///Set the slider x to the mouses x postition
};
_root.vollev.onEnterFrame = function() {
if (_root.volume.knob_mc._x>=**50** && _root.volume.knob_mc._x<**100**) { ///if knob MC's x is greater than or equal to **50** but lower than **100**
this.gotoAndStop(2); ///This, vollev image, gotoAndStop(2)
_root.voltxt = "Normal"; ///Volume status is set to normal
}
if (_root.volume.knob_mc._x<=0) {
this.gotoAndStop(5);
_root.voltxt = "Mute";
}
if (_root.volume.knob_mc._x>=0 && _root.volume.knob_mc._x<50) {
this.gotoAndStop(1);
_root.voltxt = "Low";
}
if (_root.volume.knob_mc._x>=100 && _root.volume.knob_mc._x<150) {
this.gotoAndStop(3);
_root.voltxt = "Accelerated";
}
if (_root.volume.knob_mc._x>=150 && _root.volume.knob_mc._x<200) {
_root.voltxt = "Boosted";
}
if (_root.volume.knob_mc._x>=200 && _root.volume.knob_mc._x<250) {
this.gotoAndStop(4);
_root.voltxt = "Blasting";
}
};
[color=red]Step 8; /color
The final code, balance;
////
//Balance//
//
_root.slider_mc.mask.onRelease = function() { ///on release of the slider mc's mask
_root.slider_mc.knob_btn._y = _ymouse-200; ///Set the sliders y to the mouses y - 200
};
_root.slider_mc.knob_btn.onEnterFrame = function() {
_root.speaker.balance._xscale = this._y; ///Set the _xscale of the balance meter to the balance
_root.pan = this._y; ///Pan equals the y of the slider
if (Key.isDown(Key.SPACE)) { ///If space is down
this._y -= panrightspeed; ///y goes down pan right speed
}
if (this._y<=-100) {
panrightspeed = 0;
} else {
panrightspeed = 1;///pan right speed is the speed it pans to the right
}
if (Key.isDown(Key.CONTROL)) {
this._y += panleftspeed;
}
if (this._y>=100) {
panleftspeed = 0;
} else {
panleftspeed = 1;
}
my_sound.setPan(this._y); ///Set the pan(balance) of mysound to the y of the slider
pan_txt = my_sound.getPan(); ///pan_txt is set to the balance
};
stop();
Attached: Zipped FLA [MX] 19.4Kb
Attached: Preview SWF 4.5Kb
For the FLA, try inserting in 3 sounds with linkage names, “Song 1”, Song 2", & “Song 3”.
To make a song 4; set up your song, Song 4
_root.song4.onRelease = function() {
_root.choice = "Song 4";
my_sound.stop();
_root.cseconds = 0;
_root.cminutes = 0;
_root.status = "stopped";
_root.playbut.gotoAndStop(1);
playing = false;
myMusicPosition = 0;
};