A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: HELP! Flash Buttons: How do I stop sound when next button clicked?

  1. #1
    Junior Member
    Join Date
    Mar 2010
    Posts
    8

    HELP! Flash Buttons: How do I stop sound when next button clicked?

    I'm making a page with multiple soundclips - each one launched by a separate Flash button.

    Problem: If someone clicks a button and then clicks another button without first stopping or pausing the original soundclip, the two play at the same time. Press another and three clips play at once.

    How do I make it so that when you push the next button it stops the first clip and then plays the second one?

    Any help would be greatly appreciated.

  2. #2
    Senior Member
    Join Date
    Jan 2010
    Location
    England
    Posts
    268
    hi there, welcome to the forums etc..
    you'd better be controlling those sounds with actionscript..

    if your not here's how. for each of your sounds go to your library and right click them. select "linkage" and give them an identifier that you can remember. sound1,sound2,sound3 for example.

    then paste this into the main timeline:

    Actionscript Code:
    button1.onRelease = function () {
    stopAllSounds();
    sound_for_button1  =  new  Sound(this);
    sound_for_button1.attachSound("sound1");
    sound_for_button1.start(0);
    }

    this should work for you but if not just post the new problem.change this as you need for each sound and button.
    might be addicted to flash...
    _______________________________________

  3. #3
    Junior Member
    Join Date
    Mar 2010
    Posts
    8
    Thank you very much for the reply Steve.

    This forum is for "newbies" and that term would be flattering to me so please forgive my ignorance. I understand some of what you've done here but I have a lot to learn.

    Let me explain the details. This is a favour for a musician friend because I have at least "some" web design experience - though almost none with Flash. His site is on one of those "you don't have to know anything to build your own web site" cookie cutter services. It is somewhat limiting to say the least.

    I am creating a discography which has about 2o+ rows by 4 columns. Since his site isn't accesible without a password yet I've made a basic mockup at...

    http://www.amtphoto.com/flash

    Nothing fancy, no timelines etc. In the 4th column of each row goes a link to an MP3. I have to stick to this format and it is done within a text table where I insert (into the 4th column) the following code for the Flash player...

    Actionscript Code:
    <td style="text-align: center"><span style="font-size: x-large"><object align="middle" type="application/x-shockwave-flash" data="http://www.amtphoto.com/flash/player_mp3_maxi.swf" width="56" height="26"><param name="movie" value="http://www.amtphoto.com/flash/player_mp3_maxi.swf" /><param name="bgcolor" value="#131313" /><param name="FlashVars" value="mp3=http://www.amtphoto.com/flash/ftv-bib.mp3&amp;width=56&amp;height=26&amp;showstop=1&amp;showslider=0&amp;buttonwidth=27&amp;sliderwidth=0&amp;sliderheight=0&amp;volumewidth=0&amp;volumeheight=0&amp;bgcolor=1A1A1A&amp;bgcolor1=2828DC&amp;bgcolor2=00006E" /></object></span></td>


    How do I incorporate what you've suggested into this mess?

    Thank you.

  4. #4
    Senior Member
    Join Date
    Jan 2010
    Location
    England
    Posts
    268
    oh no HTML! my one of many weaknesses!!
    its kind of the opposite with me, my HTML knowledge is very limited, iv built a few sites but nothing fancy and would you believe it, nothing with flash in it.

    what you have at the moment is good but i was under the impression that this whole thing was being built in flash. like i said im not that great at web design...yet..
    but you could make all of your "play" buttons into one swf and embed that into your webpage. so then all of the sounds are linked in one swf, if that makes any sense. and to be fair...who previews another track when the other one is still playing while there is a perfectly good stop button on the page..

    sorry i cant help you more but hopefully a more experienced user on this forum can.
    might be addicted to flash...
    _______________________________________

  5. #5
    Junior Member
    Join Date
    Mar 2010
    Posts
    8
    Well I guess I feel less humbled being here if someone else has weaknesses too! Yes I'm much better at HTML, though still nothing special.

    I like what you're saying about the one SWF player - it would certainly improve the page's load time (especially when there are 20+ buttons). Now if I only knew how! Literally I'm taking an existing flash player and just plugging it into my HTML without any real concept of how it works.

    As for "who previews another track when the other one is still playing while there is a perfectly good stop button on the page", the answer is more people than you can imagine. One thing I have learned from doing websites is that you have to childproof everything. I promise there will be plenty of guys, with seven tracks playing at once, wondering why it all sounds crap!

    Thanks again for your reply.

  6. #6
    Junior Member
    Join Date
    Mar 2010
    Posts
    8
    Can anyone see a way to use stopAllSounds() in the context of what I've done here?

    Actionscript Code:
    <td style="text-align: center"><span style="font-size: x-large"><object align="middle" type="application/x-shockwave-flash" data="http://www.amtphoto.com/flash/player_mp3_maxi.swf" width="56" height="26"><param name="movie" value="http://www.amtphoto.com/flash/player_mp3_maxi.swf" /><param name="bgcolor" value="#131313" /><param name="FlashVars" value="mp3=http://www.amtphoto.com/flash/ftv-bib.mp3&amp;width=56&amp;height=26&amp;showstop=1&amp;showslider=0&amp;buttonwidth=27&amp;sliderwidth=0&amp;sliderheight=0&amp;volumewidth=0&amp;volumeheight=0&amp;bgcolor=1A1A1A&amp;bgcolor1=2828DC&amp;bgcolor2=00006E" /></object></span></td>

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center