I have no clue how to play and stop sound. I tried everything but I guess I am doing it wrong!
basically...... the name of the clip i want to play is
sound1
i have a little play button and a little stop button
i need the code so that it will play sound1 when clicked on
and the stop button i just put stop all sounds so i guess that should take care of it..but if that is wrong then please let me know, lol
thanks
Depending on how large your sound file is one way to do it is to put the sound in its own movie clip (streaming instead of event)then control that clip with "tell target" instead of the just the sound..
Then you wouldnt need to stop all sounds..just manipulate that clip with the sound on it..
You could even resume the sound where you left off...
If the sound is huge...Youd probably want someone else here to help you out with some action script..(attach sound functions and whatnot).
Hmmm, I'd like to know how to resume a sound where it left off.....
You can also add the sound to the button timeline. Open the button timeline, add a new layer, make a keyframe on the newlayer under the down frame of the button. Drag the sound onto the stage. In Properties, in the 'Sync' box, set it to 'Start'.
No...that is not what i was talking about lol
i just need the code to put in the actions box
the code to make the "play button" play the music
and then the code to put on the stop button to stop the music
whenever i do it its like play(o) or something like that....
PLEASE HELP ME!
Nope, it's built into the down state of the button. When you press down, that tune is going to start and will play all the way through, unless you hit stop. The play button, has to be just for that play action. You can't use a copy of a button in the library, cause it adds the sound to all of them.
If you want to load the sound, which has it's advantages, do it the way JBOMBER said. Make the sound a movie clip, and load the clip, or even make it a separate swf movie, and load that. There are a lot of ways, but the button way works and it's easy.
OK! this is not working at all.....can i have one of your email address's i will send you the file then maybe you might get what i am trying to do....let me know if your still interested in helping me....email me or reply here marqi143@yahoo.com
OK! yay i got the play button to work. but guess what???? NOW I CANT GET THE STOP button to work. ok....i made a preloader in the begining of the movie on the 1st scene now when ever i publish it the preloader gets stuck......i am seriously in a world of chaos! i now have like the updated file with all problems listed above...let me know who i can send this to so you can tell me what idid wrong cause i really want to figure this out!
There was a problem with the start and stop buttons. I finally had to delete them and pull out an instance of symbol 36 and 37 to remake them clean. I added the sound to the button timeline, like I said, and the action to the stop button, so your working now. I only looped the sound 5 times, you may want to set it higher. But it is in Flash 6 now. I never asked if you were using MX or not. F5 won't do it.
Hi, I am new to this forum. I am busy building a flash site for a band but I am very new to sound in flash. I am using actionscript 2.
What I want to do with their songs is when you click on the button the song starts playing (That part I can do), what I am having trouble with is if you click the button to play "song 1" (it starts playing) and then click the button to play "song 2", I want "song 1" to stop automatically. I don't want the user to have to click a stop button.
I put the song into the song button's timeline as I am not very good with the coding in flash.
I put the song into the song button's timeline as I am not very good with the coding in flash.
DON'T DO THAT, 'cause it's a very messy way of doing so. The are tons of tutorials on the internet regarding this matter, so a quick google search wouldn't have hurt.
To accomplish this, you'll need greater control over your sounds, so coding would be an easy way out. To do this, presuming you already have a Sound file in your Library, find it there (in your Library, that is), right-click it, press Properties (or Linkage in Flash 8), expands Show Advanced, tick/check Export for ActionScript, and in the Identifier field, type in something like, sound1, and press OK. Repeat this for your second sound file, but give it a unique identifier name, like, sound2.
Presuming that you have 2 buttons on your Stage, click on one of them, open Properties Panel [CTRL+F3], and in the textfield labeled Instance Name, type in something like, song1_btn. Repeat with the second button, but give it a unique Instance name, such as, song2_btn.
Finally, select your Frame and open Actions Panel [F9], and type this:
In the first 4 lines, we create 2 Sound objects, to control each sound individually, and attach the corresponding sounds to the Sound objects (in layman's terms, we assign sound1 and sound2 from the Library to the 2 variables, so that we can play/pause them whenever we want). Next, we make song1_btn and song2_btn do something when they are pressed, and in this case, for song1_btn, we start playing sound1 and stop sound2, but for song2_btn, we start playing sound2 and stop sound1.
This may be really confusing for you, as I'm just throwing a lot of difficult code for a new beginner like you, but this is an easy outway to solve your problem. The more suitable way for you, but more time-consuming and messy, would be to add each sound in their own movieclips on the Timeline, either set the sound to Stream or use stopAllSounds() command to stop all sounds, and then control the timelines of the movieclips with the songs to play/stop them.
Hope this helps, nonetheless
17 Years old boy, who loves the Computer Technology
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
DON'T DO THAT, 'cause it's a very messy way of doing so. The are tons of tutorials on the internet regarding this matter, so a quick google search wouldn't have hurt.
To accomplish this, you'll need greater control over your sounds, so coding would be an easy way out. To do this, presuming you already have a Sound file in your Library, find it there (in your Library, that is), right-click it, press Properties (or Linkage in Flash 8), expands Show Advanced, tick/check Export for ActionScript, and in the Identifier field, type in something like, sound1, and press OK. Repeat this for your second sound file, but give it a unique identifier name, like, sound2.
Presuming that you have 2 buttons on your Stage, click on one of them, open Properties Panel [CTRL+F3], and in the textfield labeled Instance Name, type in something like, song1_btn. Repeat with the second button, but give it a unique Instance name, such as, song2_btn.
Finally, select your Frame and open Actions Panel [F9], and type this:
In the first 4 lines, we create 2 Sound objects, to control each sound individually, and attach the corresponding sounds to the Sound objects (in layman's terms, we assign sound1 and sound2 from the Library to the 2 variables, so that we can play/pause them whenever we want). Next, we make song1_btn and song2_btn do something when they are pressed, and in this case, for song1_btn, we start playing sound1 and stop sound2, but for song2_btn, we start playing sound2 and stop sound1.
This may be really confusing for you, as I'm just throwing a lot of difficult code for a new beginner like you, but this is an easy outway to solve your problem. The more suitable way for you, but more time-consuming and messy, would be to add each sound in their own movieclips on the Timeline, either set the sound to Stream or use stopAllSounds() command to stop all sounds, and then control the timelines of the movieclips with the songs to play/stop them.
Hope this helps, nonetheless
Thank you for your help. I will attempt to use the codes you have given me and try to fix my problem. If I still struggle I will let you know.
Somewhere I am doing something very wrong as I cannot get it to work... I followed your guide step by step but somewhere I am missing something as the songs don't want to play.
Just a couple of questions:
1) Must the buttons be on the same layer? They were on different layers when I tried it the first time (it didn't work) so I moved them to the same layer (still doesn't work though).
2) I tried the code in the frame (of the buttons) when I moved the buttons onto the same layer and I also tried it in the actions for the buttons themselves. (Yes, I am desperate to get this right).
Any other help you can give me would be great as I need this to work.
Last edited by IncomingVirus; 05-15-2012 at 08:28 AM.
The layer they're on doesn't count, and you don't apply the code to the buttons, but to the FRAMES
Click on any Layer's Frame (preferably a frame with one of the buttons), press F9 to open Actions Panel, and then add the code I've provided. You are not applying the codes to the buttons themselves, but to the Frames.
17 Years old boy, who loves the Computer Technology
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
I did, but it still does not work. There is no sound, the songs won't play at all. I am using CS4 Actionscript 2 if that helps at all but will be upgrading to CS5 soon.
You don't apply the code to a Frame inside the button, but on a Frame OUTSIDE both of the buttons on the main stage, if that still doesn't work, then would you mind posting your FLA File?
17 Years old boy, who loves the Computer Technology
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
My file is way too big and even when I compress it I can't get it down to the allowed size for uploading as the size limit is 300kb and my file when compressed is 22mb.