Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating soundtracks with buttons? 1

Status
Not open for further replies.

TheOdditie

Technical User
Mar 11, 2003
24
US
Alright, I'm a little new to Flash. I have messed with it before, but that was about a year ago, and even then I didn't have the best of luck with buttons. My first question is:
What is the best way to create a flash soundtrack for a website? Like you go to a bands website and they have like 5 different songs you can listen to while you browse their page, well I would like to do something like that, and would like to know the best/easiest way to do it.
My second question is:
Alright, I have thought of one way of doing the above, to create a movie with several scenes in it and each scene gets its own track except for the first scene that has the controls. Well I have gotten the play button to work, the only button i have tried so far, but if you click the play button again, it will start playin the song again without stopping the first one, it will just keep adding the song on there. How would I make it so that it will only play 1 song at a time? Hope that made sense. Thanks in advance.

TheOdditie
 
alright, i have done what you said, exactly what you said, and it still doesn't work. I have it up at my site

I put the mp3s in the same folder as the swf, put the exact script you told me to put on the next button, and i still get nothing.

oh yea, i had to take down the .fla and .swf file i put up earlier, this stuff takes a lot of memory away.
 
Well I didn't have time to get your .fla, so I guess I don't get a crack at this? Regards,

oldman3.gif
 
got an e-mail addy i can send it too? if so i will e-mail it to you. sorry, it was just taking up too much space. I don't have that much space really to begin with, only 25 mb.
 
Hit my handle for address. Hope it's under 1MB, it's an Hotmail account. Zip it up! Regards,

oldman3.gif
 
do you got winrar? if so i can zip it up pretty good, if not, it won't hardly zip it
 
Ok! Could get my hands on track0, track1 and track3. track2 doesn't seem to exist and are they more then 4 tracks? Regards,

oldman3.gif
 
uhhh...hang on, let me upload track2 again and get track4 up there
 
alright, well there wasn't a track2, guess i can't count, and i didn't notice the size that i had track4 at until just now, so i just got rid of it.

So just rename track3 to track 2. Ill just have 3 tracks right now.

thanks alot man.
 
Do me a favor! To allow me to further test this before I post my code, please rename your 3 tracks in your "music" folder track1.mp3, track2.mp3, track3.mp3.
Seems more logical to me anyways since track0.mp3 seems weird!

Got this going on the &quot;>>&quot; button, will now check the &quot;<<&quot; button, but what about the &quot;>&quot; button, what should that do? re-satrt the track that was last selected, or re-start from track 1 after a press on the &quot;stop&quot; button.

Furthermore you do realize, that as it is now, the sounds are set to stream, so it does take a few seconds (+/-5 to 10 seconds) for the sound to start playing and that's with a cable connection. Will take much longer on a dialup! Regards,

oldman3.gif
 
alright, yea i can rename the tracks. Can you get the &quot;>&quot; button to start at whatever song its sitting on, like if the user stops the song on track3, then they hit play again it starts on track3, if not thats fine, just have it start on track1

yes i realize they are set to stream and will take a while for dailup, that is why i have the buttons there, instead of forcing the user to listen to music.

Thank you so much for this man, i tried on it, but just can't figure it out. I appreciate it so much.
 
Oh thank you so much man. What would make it so that it wouldn't take a couple secs to go? or would it be too big of a hassle to do? i should have asked earlier, but no, i didn't think about it. can you send me the .fla back?

also, what would get the play button to start up on the current track?
 
Streaming the songs is the fastest way to play them and hear something. If you were to change them to &quot;event&quot; sounds, then they would have to completely download before they start playing.

Will e-mail you the .fla, but will post the code here for the benefit of others, following this thread. Maybe even for Bill!

Have now set it up so that, if some song is not already playing, then the play button allways starts the first track. If some some song is already playing, then the play button has no effect. Once the stop button has been pressed, then the play button will allways re-start the first track playing again.

If you decide to add more tracks, then some code lines would have to be uptaded to reflect the total number of tracks. For now this cycles through 3 tracks only.

The &quot;<<&quot; button:
Code:
on (release) {
	mysound.stop();
	index -=1;
	if (index < 1){
		index = 3;
	} 
	song = &quot;track&quot; + _root.index + &quot;.mp3&quot;;
	//trace (song);
	mySound = new Sound(this);
	mySound.loadSound(&quot;[URL unfurl="true"]http://www.teamlonelydrivers.com/music/&quot;+[/URL] song, true);
	//mySound.loadSound(&quot;track&quot;+index+&quot;.mp3&quot;, true);
	mySound.start();
 }
* Note: no linebreak in the first &quot;loadSound&quot; above!

The STOP button:
Code:
on (release) {
 	stopAllSounds();
	// Or... mySound.stop();
	index = 0;
	mySound = false;
}

The &quot;>&quot; button:
Code:
on (release) {
	if (!mySound){
		index +=1;
		if (index > 3){
			index = 1;
		}
		song = &quot;track&quot; + _root.index + &quot;.mp3&quot;;
		mySound = new Sound(this);
		mySound.loadSound(&quot;[URL unfurl="true"]http://www.teamlonelydrivers.com/music/&quot;+[/URL] song, true);
		//mySound.loadSound(&quot;track&quot;+index+&quot;.mp3&quot;,
true);
		mySound.start();
	} else {
		mySound.start();	
	}
}
* Note: no linebreaks in the &quot;loadSound&quot; actions above!

The &quot;>>&quot; button:
Code:
on (release) {
	mysound.stop();
	index +=1;
	if (index > 3){
		index = 1;
	}
	song = &quot;track&quot; + _root.index + &quot;.mp3&quot;;
	//	trace (song);
	mySound = new Sound(this);
	mySound.loadSound(&quot;[URL unfurl="true"]http://www.teamlonelydrivers.com/music/&quot;+[/URL] song, true);
	//mySound.loadSound(&quot;track&quot;+index+&quot;.mp3&quot;, true);
	mySound.start();
	if (index > 2){
		index = 0;
	} 
}
* Note: no linebreak in the first &quot;loadSound&quot; above!

There might still be problems (path) if loading this player in another movie, but I don't really think so. Anyway, it could be fixed.

Enjoy!

Regards,

oldman3.gif
 
Just noticed I left some first coding in there...

In every line song = &quot;track&quot; + _root.index + &quot;.mp3&quot;;, the &quot;_root&quot; is not necessary, and might even cause some errors, in other situations.

This would be enough...

song = &quot;track&quot; + index + &quot;.mp3&quot;;

Sorry about that!

Regards,

oldman3.gif
 
Buttons are wonderful OldNewbie. Thank you so much. The play button, if the song ends up playing all the way through, will pick back up on the track it left off on. Still they are great, thanks alot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top