Last time I’ve showed you how to create a basic mp3 streaming player using XML, you got all the basics you need, you have the functionality, you got the code. Now it’s time to show you a bit more that is needed/possible.
Upon request on the forum, I will show you this:
Let us start with something easy.
Display of further elements (like artist)
Maybe you already found on the P2L forum a topic regarding this mp3 player, and someone that didn’t knew how to put the artist/group on the same text field.
Here’s how I’ve solved his problem.
XML:
I’ve just created a new attribute called band:
1 | <song name ="Test1" band ="Twodded Band" file="test1.mp3"/> |
FLASH:
1 2 3 4 | playlist.onLoad = function (success) { if(success) { _global.songname = []; ....... |
Last time we defined a global variable holding the name of the mp3 file we stored in our XML.
So I’ve just set a new variable named “songband”
1 2 3 4 | playlist.onLoad = function (success) { if(success) { _global.songname = []; _global.songband = []; |
But that’s not everything.. We also need to define it on other lines of our actionscript.
Here you see our array for the songname:
1 2 3 | ... _global.songname[i] = playlist.firstChild.childNodes[i].attributes.name; ... |
So now we just need to add a new line with following code:
1 | _global.songband[i] = playlist.firstChild.childNodes[i].attributes.band; |
we’ve already set a variable named “songband” and now we’re creating a new array for that variable to hold our data.
If you want to test if everything works, just place a trace action on the script:
1 | trace(songname[i]+" "+songfile[i]+" "+songband[i]); |
If you XML is correct and every step till now has been done you should get this as output:
Test1 test1.mp3 Twodded Band
Test2 test2.mp3 P2L Band
When we create our soundobject we passed the array with it, so we can display the name and play the file.
1 2 3 4 | _root.createEmptyMovieClip("sound_mc",1); _root.sound_mc.sound_obj = new Sound(); _global.song_nr = random(songfile.length); _root.sound_mc.songStarter(songfile[song_nr],songname[song_nr); |
Now things are starting getting easier and easiert or not? I think you already guessed what you need to put here:
1 2 3 4 5 | _root.createEmptyMovieClip("sound_mc",1); _root.sound_mc.sound_obj = new Sound(); _global.song_nr = random(songfile.length); _root.sound_mc.songStarter(songfile[song_nr],songname[song_nr],songband[ song_nr]); |
Now where can I see the Bandname on my movie?
Do you remember this piece of code?
1 2 3 4 5 6 7 | MovieClip.prototype.songStarter = function (file, name, band) { this.sound_obj.loadSound(file,true) this.onEnterFrame = function () { if(this.sound_obj.position>0) { delete this.onEnterFrame; this._parent.display_txt.text=name; ..... |
You noticed already that I’m displaying the name of the track using this _parent.display_txt.text=name;
so we now just add the band name to it, how?
We just tell to append a whitespace a slash and a whitespace and then show the band name.
Since we are working with textfields, you can enter whatevery you want to be showed inside of the “”.
1 | this._parent.display_txt.text=name+" / "+band; |
Now do a test run on your movie, and you will see that the bandname is being displayed. Kewl uh!
Nevertheless, we’re still not done as soon as you push a button or the track ends, all the next tracks will not have any band description on it, we didn’t define to do so.
As you see I defined the songband array for every possible state
(soundcomplete, play, next and back)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | this.sound_obj.onSoundComplete = function () { (song_nr==songfile.length-1)? _global.song_nr=0 : _global.song_nr++; _root.sound_mc.songStarter(songfile[song_nr],songname[song_nr],songband[ song_nr]); } } btn_play.onRelease = function () { this._parent.sound_mc.songStarter(songfile[song_nr],songname[song_nr],so ngband[song_nr]); } btn_stop.onRelease = function() { this._parent.sound_mc.sound_obj.stop(); } btn_fw.onRelease = function () { (song_nr==songfile.length-1)? _global.song_nr=0 : _global.song_nr++; _root.sound_mc.songStarter(songfile[song_nr],songname[song_nr],songband[ song_nr]); } |
This method can be used for every kind of text input that you want to push with your song.
The First part of this tutorial is done, let’s see what we can do else..
Are you still with me? Congrats you will get rewarded with a … Time Display
First off, we create a new dynamic textfield in our stage and give it the instanceName of timeDisplay_txt, we also type 00:00 into that textfield since we don’t want that the scripted counter just pops up.
How do we want to display our time? normally cd players just show minutes and seconds of each track, some of those also show miliseconds.. but hey.. we don’t need those.
So let us set a Interval of one second.
timeInterval=setInterval(timer,1000);
Timer is the name of our function that we will write, and 1000 means, every 1000ms should this function being called.
I will place the interval inside of the prototype just after the text display we did before.
As next we need to create our function that will output the playtime of our mp3 file.
For the beginning let us just trace it to test if it works
1 2 3 | function timer(sound_obj) { trace(sound_obj.position); } |
This code has been placed before the prototype, basically you could post it anywhere, as long as it’s not inside any loop or query.
Press CTRL+ENTER to test your movie and you will see that besides of the
xml information we pulled before, we also get some strage numbers, those
are being update every second.. you remember that we set our interval to
1 second. And the time is being displayed in miliseconds. No one will
want to read that as it is, so let’s change it to something more
userfriendly.
To achieve it, we need to work a little bit more, first of all..
Let us remove that trace action and replace it with
this:
1 | timeDisplay_txt.text=sound_obj.position; |
Now you see our miliseconds being displayed in our textfield we created.
Next we need to make time readable for everyone.
Let us store our time inside a variable, so we don’t have to type so much and convert it right away to seconds.
1 | time=sound_obj.position/1000; |
I’ve replaced sound_obj.position with time to display the time:
1 | timeDisplay_txt.text=time; |
Now we have a more or less readable timeformat, but we can do it better.
Let us divide the time by 60 so that we have minutes
1 | min=Math.floor(time/60); |
Now that we have our minutes, we also need to define the seconds, that are available from this song. For this we will going to use Modulo = %
Now what is modulo?
% (modulo)
Availability
Flash Player 4. In Flash 4 files, the % operator is expanded in the SWF file as x – int(x/y) * y, and may not be as fast or as accurate in later versions of Flash Player.Usage
expression1 % expression2Parameters
None.Returns
Nothing.Description
Operator (arithmetic); calculates the remainder of expression1 divided by expression2. If either of the expression parameters are non-numeric, the modulo operator attempts to convert them to numbers.
The expression can be a number or string that converts to a numeric value.Example
The following is a numeric example that uses the modulo (%) operator.
1 2 3 4 trace (12 % 5); // returns 2 trace (4.3 % 2.1); // returns approximately 0.1
In our case, if our song has a length of 80 seconds then we calculate 80%60 equals 20, 60 fits once in 1 and 20 is the rest. resulting in 01:20.
the code needed for this calculation is very easy!
1 | sec=Math.floor(time%60); |
Now we have also our seconds.
Now there’s still one small thing that I forgot. When time is under 10 seconds we want to show the seconds with a 0 in front. We need to write a query for that.
Lets append our code with this line
1 | sec=(sec<10)?"0"+sec:sec; |
In our case we are not using any mp3′s longer then 1 minute but for any case, here the code for the minutes.
1 | min=(min<10)?"0"+min:min; |
Last step will be the display of the correct time in our textfield, go back to our display code and replace time with min+”:”sec”;
1 2 3 4 5 6 7 8 | function timer(sound_obj) { time=sound_obj.position/1000; min=Math.floor(time/60); min=(min%lt;10)?"0"+min:min; sec=Math.floor(time%60); sec=(sec<10)?"0"+sec:sec; timeDisplay_txt.text=min+":"+sec; } |
If you test the movie now you will see that our display is working correctly.. till….
…the song ends… or you press any button…
There is good way to fix the whole problem, we just need to clear interval and set the time back to 00:00. I will show you here how to fix that.
On the onSoundComplete event we need to clear the interval and set the time back, we do that with this piece of code:
1 2 | clearInterval(timeInterval); this._parent.timeDisplay_txt.text="00:00"; |
Here the complete onSoundComplete code piece:
1 2 3 4 5 6 7 | this.sound_obj.onSoundComplete = function () { clearInterval(timeInterval); this._parent.timeDisplay_txt.text="00:00"; (song_nr==songfile.length-1)? _global.song_nr=0 : _global.song_nr++; _root.sound_mc.songStarter(songfile[song_nr],songname[song_nr],songband[ song_nr]); |
}
Now the time will be display correctly as long as you don’t push any button.
To fix that, let us remove the sound_obj creation inside the onload function
1 | _root.sound_mc.sound_obj = new Sound(_root.sound_mc); |
remove this..
And we will create the soundobject inside our prototype.
First we check if there is a soundobject.
1 2 3 4 5 6 7 8 | if (this.sound_obj){ If there is one we stop it. this.sound_obj.stop(); If there is one we delete it. delete this.sound_obj; } If there is no sound object then create one. this.sound_obj=new Sound(this); |
Before you test the movie place this piece of code on every button you
have:
1 2 | clearInterval(timeInterval); this._parent.timeDisplay_txt.text="00:00"; |
Here the complete button code now:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ... btn_play.onRelease = function () { clearInterval(timeInterval); this._parent.timeDisplay_txt.text="00:00"; this._parent.sound_mc.songStarter(songfile[song_nr],songname[song_nr],so ngband[song_nr]); } btn_stop.onRelease = function() { clearInterval(timeInterval); this._parent.timeDisplay_txt.text="00:00"; this._parent.sound_mc.sound_obj.stop(); } btn_fw.onRelease = function () { clearInterval(timeInterval); this._parent.timeDisplay_txt.text="00:00"; (song_nr==songfile.length-1)? _global.song_nr=0 : _global.song_nr++; _root.sound_mc.songStarter(songfile[song_nr],songname[song_nr],songband[ song_nr]); } btn_rev.onRelease = function () { clearInterval(timeInterval); this._parent.timeDisplay_txt.text="00:00"; (song_nr==0)? _global.song_nr=songfile.length-1 : _global.song_nr--; _root.sound_mc.songStarter(songfile[song_nr],songname[song_nr],songband[ song_nr]) } |
Now test your movie. Happy with it? Still want to learn more, then just jump to next page to learn …..
The volume Slider
Okay.. this is the last part of this tutorial, if you are still with me then grab some coke and something to eat, after this you will be playing around with your mp3 player till early morning.
Design some shape to act as background of your volumeslider, I just draw a square and moved the top left corner point throughout the bottom, so I have a more stylish volumeslide background. I didn’t put much effort on the design since this is a pure actionscripting tutorial
Select the newly created shape and convert it to a movieclip, give it also a instancename of volBG.
Now create a handle where the user can lower or maximize the volume, I’ve just draw a rectangle and placed it ontop of the volBG. Again convert this shape to a movieclip, and give it a instancename of dragger
Now select both mc’s and convert them also to a movieclip with the instance name volume1.
Right after the soundcomplete function we will place our actions for the volume dragger.
1 2 3 4 5 6 7 | this._parent.volume1.dragger.onPress = function(){ startDrag(this, true,0,this._y,this._parent.volBG._width,this._y); } this._parent.volume1.dragger.onRelease = function(){ stopDrag(); } |
Here we tell our dragger that he’s draggable
on the X-Axis it would be moved from 0 to the width of the volBG mc and I’ve also locked the Y-Axis since we don’t need to drag it vertically.
As soon as the mousebutton is released we want to stop drag, just put this action into the onRelease function
stopDrag();
Just do a small test of your movie, to check if your dragger is working as it should and if you can’t drag over the volBG.
Everything working as it should? Good!
Let’s move on to the last part of this tutorial
We want to control the volume of the sound depending on the position of the dragger.
1 2 3 4 | this.onEnterFrame = function () { var g = (this._x/this._parent.volBG._width)*100; this._parent._parent.sound_mc.sound_obj.setVolume(g); } |
Okay, we create an onEnterFrame function to control the sound, inside of that function I’ve created a new variable holding the percentage of our volume by diving the dragger by the width of the volBG and multiplying it by 100.
If we don’t multiply it you will get a too low value to regulate the volume.
Then we just need to set the volume of the sound_obj to the variable “g”.
Here the COMPLETE code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | stop(); playlist = new XML(); playlist.ignoreWhite=true; playlist.onLoad = function (success) { if(success) { _global.songname = []; _global.songband = []; _global.songfile = []; for (var i=0; i<playlist .firstChild.childNodes.length; i++) { _global.songname[i] = playlist.firstChild.childNodes[i].attributes.name; _global.songband[i] = playlist.firstChild.childNodes[i].attributes.band; _global.songfile[i] = playlist.firstChild.childNodes[i].attributes.file; //trace(songname[i]+" "+songfile[i]+" "+songband[i]); } } _root.createEmptyMovieClip("sound_mc",1); _global.song_nr = random(songfile.length); _root.sound_mc.songStarter(songfile[song_nr],songname[song_nr],songband[song_nr]); } function timer(sound_obj) { time=sound_obj.position/1000; min=Math.floor(time/60); min=(min%lt;10)?"0"+min:min; sec=Math.floor(time%60); sec=(sec<10)?"0"+sec:sec; timeDisplay_txt.text=min+":"+sec; } MovieClip.prototype.songStarter = function (file, name, band) { if (this.sound_obj){ this.sound_obj.stop(); delete this.sound_obj; } this.sound_obj = new Sound(this) this.sound_obj.loadSound(file,true) this.onEnterFrame = function () { if(this.sound_obj.position>0) { delete this.onEnterFrame; this._parent.display_txt.text=name+" / "+band; timeInterval = setInterval(timer, 1000, this.sound_obj); } else { this._parent.display_txt.text="loading..." } } this.sound_obj.onSoundComplete = function () { clearInterval(timeInterval); this._parent.timeDisplay_txt.text="00:00"; (song_nr==songfile.length-1)? _global.song_nr=0 : _global.song_nr++; _root.sound_mc.songStarter(songfile[song_nr],songname[song_nr],songband[song_nr]); } this._parent.volume1.dragger.onPress = function() { startDrag(this, true, 0, this._y, this._parent.volBG._width, this._y); this.onEnterFrame = function() { var p = (this._x/this._parent.volBG._width)*100; this._parent._parent.sound_mc.sound_obj.setVolume(p); }; } this._parent.volume1.dragger.onRelease = function() { delete this.onEnterFrame; stopDrag(); }; this._parent.volume1.dragger.onReleaseOutside = function() { stopDrag(); }; } btn_play.onRelease = function () { clearInterval(timeInterval); this._parent.timeDisplay_txt.text="00:00"; this._parent.sound_mc.songStarter(songfile[song_nr],songname[song_nr],songband[song_nr]); } btn_stop.onRelease = function() { clearInterval(timeInterval); this._parent.timeDisplay_txt.text="00:00"; this._parent.sound_mc.sound_obj.stop(); } btn_fw.onRelease = function () { clearInterval(timeInterval); this._parent.timeDisplay_txt.text="00:00"; (song_nr==songfile.length-1)? _global.song_nr=0 : _global.song_nr++; _root.sound_mc.songStarter(songfile[song_nr],songname[song_nr],songband[song_nr]); } btn_rev.onRelease = function () { clearInterval(timeInterval); this._parent.timeDisplay_txt.text="00:00"; (song_nr==0)? _global.song_nr=songfile.length-1 : _global.song_nr--; _root.sound_mc.songStarter(songfile[song_nr],songname[song_nr],songband[song_nr]) } playlist.load("playlist.xml"); </playlist> |
And that’s it, there you have your volumebar.
That’s it for part II of the Streaming MP3 player,
HERE you can download a .zip file containing the .fla, .xml and 2 sample mp3′s to play around with.
I hope you enjoyed this tutorial.
Tiago Dias



Is there a way to manually start the songs and make the song stop at the end of each song?
great work, im still following along, however I am having a problem. When I click the voume slider, it jumps to the middle of the volBG and then it scrolls from there, but goes off the screen. I may have mis-typed something.
Great work, easy to follow along with!
Travis:
Remove line 20 to switch off autoplay
Remove line 52 to stop the player after a song has completed
Chuck:
The only reason I can see is that you worked on a different registration point, normally registration points should be on the top-left corner of the object.
thank you
Hi, I’m trying to put an equalizer on my mp3 player but I cant not turn it off. Please advise…I’m using the tutorial at this equalizer
my flash movie hang when i use the turnOff(); function. Do you know how to turn on/off the eq. Please help me…
Thanks
Mike T
Mike, Try to use another letter then I on the visualizer.
Hi,
Great Tutorial
Is there anyway to turn the buttons created from the xml file off and on?.
At the moment (if i havent done somthing wrong) they are overlaying everything in my flash project and i only want them to be viable when you are viewing the music page.
Many Thanks
Mark
Great player easy to customize, really thank you so much, is there a way to make the text scroll if its too long? and im thinking in adding an image from the XML so it can be displayed ill tell you how that goes!
Hi,
It’s a great tutorial and i learn many things. But I’ve some problem. Actually when i click on play button in the playing mode rather than stop mode, the name display box shows undefined. Tiago can u help me?
Hi,
It`s realy good player. Verry easy for use and help me a lot, but i have one problem.
Is this posible to turn off autoPlay when flash begin. I write upper that i must remove line 20 and line 52 but there is a roblem. When i remove this lines player stop working.
Tiago – Thanks for this great tutorial…
I have been working with your tutorial source files that I downloaded, but can’t seem to get them to load the songs. I downloaded the files, edited the XML to include the proper file paths, arranged the xml, swf, and mp3 flies in the same folder, but they never seem to load. What am I doing wrong?
Far out this is just what I was looking for. Thank-you for making this available, it works like a charm. One question, it appears the first song is loaded from the XML file in a random order. One time it is the first in the xml list, next time it is the thrid, etc. How can I specify that the last song should be played first?
thanks in advance… Michael
Bspring: Please see notes here (bottom of page) for fixing your issue with path to XML file
great tutorial. I’m having problems with my stop button, every time i press stop and then click play, or accidentally click play twice the song display say “undefined” what am i doing wrong. I’m using flash 8.
Cheers
nice tut
ive got a problem with the speed of played mp3 its just going to fast it plays something about twice of normal speed
any ideas wheres the problem??
urbanczyks
Flash 8 doesn’t support all ranges of khz encodings, have a look at the post I wrote a while ago
http://blog.six4rty.ch/2007/08/08/flash-mp3-and-the-mickey-mouse-effect/
Soul
Can you send me your fla file, I don’t see that problem on my player
Michael
Thanks for the help
Dobromir
Check the comments on part 1 of this tutorial, that question has been already answered a few times
Benji
Check out part 3 of this tutorial, there you will learn how to create the scrolling text and much much more
thx Tiago4 help didint know about the MM problem
nice tutorial, i tryed to add two buttons to contrl volume, my code
this.onEnterFrame = function() {
//////////////////////////////////////////////////////
volume_value = (this._x/this._parent.volBG._width)*100;
//this._x._parent.volBG._width=50;
//this._parent.volBG._width=50;
vol_up.onPress = function()
{
this.dragger._x += 2
volume_value += 2
//this._parent.volBG._width=volume_value;
_root.value_a.text= volume_value;
this._parent.sound_mc.sound_obj.setVolume(volume_value);
if (volume_value >= 100)
{
volume_value = 100
}
}
vol_dn.onPress = function()
{
this.dragger._x -= 2
volume_value -= 2
//this._parent.volBG._width=volume_value;
_root.value_a.text= volume_value;
this._parent.sound_mc.sound_obj.setVolume(volume_value);
if (volume_value <= 0)
{
volume_value = 0
}
}
//////////////////////////////////////////////////
// set volume
this._parent._parent.sound_mc.sound_obj.setVolume(volume_value);
};
but itz not working, can you please help me!
please someone help me…….
tiago please help me
i got another problem, i want to add scroll bar to my player, but itz not working, help me, i really approciate your kindness.
Hi, I love this blog as well as this tutorial, it is very informative. Unfortunately I have just ventured into Action Script so things are a bit difficult for me. I have a peculiar problem. Can you please help fix it?
I have downloaded your audioplayer.fla and it works fine in my Flash 8 Professional, have changed the publish settings to Flash 8, also action script to version 2. Everything works out fine when I test the movie. However when I simply copy and paste the frames into another .fla of mine (with exactly the same publish settings), the player works only partially. The forward and backward buttons work, the timer works, the songs also play. But here the dynamic text for the song title does not work at all, plus the ‘play’, ‘stop’ and the volume ‘slider’ does not work.
Can you tell me how to fix this? I wld really apperciate it. Thanks a ton.
Tiago,
I would like the volume not to be all the way up when the song loads. Initially my volume slider is half way up but the the volume is all the way up. when the user clicks my dragger the volume abruptly changes to 50% lower.
What I would like to do is set the volume to 50% when the song loads so it will match the slider position
What is the proper way to accomplish this?
Harish
can you have a try with part3 of this tutorial download those files and let me know if it still doesn’t work.
Sojourner
access the fader mc and change the value 99 to 50, aswell double click on the volume mc and position the dragger at 44px on the X axis
If you want you can also remove the fader clip and create a new variable at the beginning of our main scene on frame 1.
var p = 50; // p is the volume of our player
Hi Tiago,
thanks for the prompt reply. Actually I wanted to use the player in part 2 as it is small and compact, as I have less space on my page, also I feel the part 2 player looks very sleek, I love it. Actually I think I have fixed the problem partially, at least I know now why the part 2 player did not fully work in my fla when it was working perfectly on its own( both files in Flash pro 8 , with AS2)
The problem has to do with the player being on the root of the main movie. When I paste the player on the root of my fla movie, it works perfectly. However, when I try to paste in in a movie clip, or even try to load it externally, it works only partially( the play and stop button do not work, also the slider, also the name of the clip does not show. However, the forward and backward button and the timer work.)
Can you please figure out away to fix this for me? As I am not that well versed with AS.
Thanks once again!
Harish
you just need to replace the “_root” tags with the “this” tags
Hi, thanks again Tiago, will try what you said and get back to you, hope it works for me now. For I do not know AS well, have just begun to learn it.
thanks a ton!
Hi Tiago, Thanks again for your great player. I still am wondering how can I prevent the audio files from being loaded at random and play them in the order they are in the file?
Hi Michael, find this line of code
and replace with this one:
Awesome Tiago, thanks for such a prompt response. Check out your player in action at my client site
Hello, I am having the same problem as harish had and am wondering if you have a solution to the problem he asked you. I tried your suggestion of replacing the _root tags with this tags but that unfortunately didn’t work. Do you have any other suggestions? Thanks!
to stephen…
As soon as you place the complete mp3 player code inside of a movieclip you need to point the actions to the correct mc. in case you placed your mp3player into an mc called mp3Player, then your actions would look like this:
mp3Player.btnPlay.....instead of
_root.btnPlay....So if this is the actionscript for the mp3 player when it is in the root folder, what would it look like if it were inside a movieclip called “musicplayer”? I tried changing the _root.something to musicplayer.something and that unfortunately didn’t resolve my issue. The play/stop buttons, song name and volume slider still do not work. Any ideas? Thanks for all your help and the prompt response!
stop();
playlist = new XML();
playlist.ignoreWhite = true;
playlist.onLoad = function(success) {
if (success) {
_global.songname = [];
_global.songband = [];
_global.songfile = [];
for (var i = 0; i<playlist.firstChild.childNodes.length; i++) {
_global.songname[i] = playlist.firstChild.childNodes[i].attributes.name;
_global.songband[i] = playlist.firstChild.childNodes[i].attributes.band;
_global.songfile[i] = playlist.firstChild.childNodes[i].attributes.file;
// trace(songname[i]+” “+songfile[i]+” “+songband[i]);
}
}
_root.createEmptyMovieClip(“sound_mc”, 1);
_global.song_nr = random(songfile.length);
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
function timer(sound_obj) {
time = sound_obj.position/1000;
min = Math.floor(time/60);
min = (min<10) ? “0″+min : min;
sec = Math.floor(time%60);
sec = (sec0) {
delete this.onEnterFrame;
this._parent.display_txt.text = name+” / “+band;
timeInterval = setInterval(timer, 1000, this.sound_obj);
} else {
this._parent.display_txt.text = “loading…”;
}
};
this.sound_obj.onSoundComplete = function() {
clearInterval(timeInterval);
this._parent.timeDisplay_txt.text = “00:00″;
(song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
this._parent.volume1.dragger.onPress = function() {
startDrag(this, true, 0, this._y, this._parent.volBG._width, this._y);
this.onEnterFrame = function() {
var p = (this._x/this._parent.volBG._width)*100;
this._parent._parent.sound_mc.sound_obj.setVolume(p);
};
};
this._parent.volume1.dragger.onRelease = function() {
delete this.onEnterFrame;
stopDrag();
};
this._parent.volume1.dragger.onReleaseOutside = function() {
stopDrag();
};
};
btn_play.onRelease = function() {
clearInterval(timeInterval);
this._parent.timeDisplay_txt.text = “00:00″;
this._parent.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
btn_stop.onRelease = function() {
clearInterval(timeInterval);
this._parent.timeDisplay_txt.text = “00:00″;
this._parent.sound_mc.sound_obj.stop();
};
btn_fw.onRelease = function() {
clearInterval(timeInterval);
this._parent.timeDisplay_txt.text = “00:00″;
(song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
btn_rev.onRelease = function() {
clearInterval(timeInterval);
this._parent.timeDisplay_txt.text = “00:00″;
(song_nr == 0) ? _global.song_nr=songfile.length-1 : _global.song_nr–;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
playlist.load(“playlist.xml”);
Stephen
Are your actions also placed inside the movieclip?
Yes they are. Both layers of the original script are inside the movieclip. Is this a problem?
Yes they are. Both layers are within the movieclip. Is this a problem?
yes they are. Both layers from the original fla are within the movieclip. Is this a problem?
Yes they are. Both layers are within the movieclip.
Yes they are. Both the actions and controls layer are within the movieclip.
Yes the actions are placed within the movieclip as well Is this a problem?
Yes my actions are placed inside the movieclip.
Yes they are.
yes, they are.
Great tutorial man. Easy to understand etc. Well done and thanks for sharing.
sorry for all the posts…i tried it multiple times cause they weren’t appearing until now.
Got a lot of respect for Tiago.
Sick design of a web site, good outlook on life and great tutorials.
Now, to the negative points
I’ve downloaded Part III, opened the .swf but it didn’t play. Just kept saying ‘Loading…’.
Am I doing something wrong?
I literally changed nothing, just extracted the folder, and opened the swf
Any pointers?
Anyone know how to set the default value for Volume?
It’s too loud when I load it, and I’d like to start it about 50%.
Anyone?
Michael
You can set the volume by adding this line after the soundobject has been created:
Be aware that this only works for Actionscript 2.0 projects
Hi,
Sorry to bring up the same subject again, but I am not advancing in trying to get the title to show.
I am using template http://www.templatemonster.com/flash-templates/12730.html
and I am trying to get the player on the third tab (musical composition). This is in a container called block03_03 which is in a container called cont. But whatever I change to the path, it doesn’t show the title. Only if I place the display_txt box directly on the scene_1 . Or, as adviced by you guys, putting it in a mc and changing the path to _root.mc. But if I then want to place that mc into the third tab (the block03_03), it stops working as well.
I did some debugging and apparently the display_txt shows under:
_level0.cont.bloc3.instancexxx.display_txt
but I don’t know what to do with that because the instancenumber changes…
Any clue?
cheers
Hi there.
I’ve made my xml fed mp3 player a slightly different way. I have the song names as buttons and when clicked the songfile index gets loaded into the sound object. My problem is that I want the next song to start onSoundComplete. I’m having trouble figuring out a way for the onSoundComplete function to know what songfile index is currently playing.
Is this even possible? If not I’ll go with the standard version. Any help would be great!
A
Hey!
I figured it out, so no worries. Thanks for blogging.
A