A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: fading out sounds with a button

  1. #1
    Junior Member
    Join Date
    Aug 2001
    hey i was wondering if there was any particular code to fade out sounds with the press of a button within the movie, also i was wondering if you can fade sound in once and then have it loop contiunesly at the normal sound volume...if someone can get back to me that would be great...

  2. #2
    Senior Member
    Join Date
    Apr 2002
    The easiest way to do this is with Sound Objects, which include a setVolume option that can be driven by a variable.

    buttonone=new Sound();

    Here's a way to fade using Sound Objects:

    When you press your button:

    on(press) {soundfade=1}
    Then on a movieclip that loops:

    onClipEvent (load) {
    _global.i = 75;
    s = new Sound();
    onClipEvent (enterFrame) {
    if (soundfade==1) {

    The following is a mini-tutorial I wrote for someone else on using sound objects. It might help you.

    1. Locate each of the three sounds in your library and right click them.
    2. Select "Linkage" then select "Export for Actionscript."
    3. In the window that will then appear, enter an ID for the sound, e.g., buttonsound01. For the next, use buttonsound02, etc.
    4. You need to define the sound object before you can use them in your buttons. To do this, create an empty movieclip and drag it out on stage.
    5. In the first frame of this mc, type:

    buttonone=new Sound();
    buttontwo=new Sound();
    Similar for button 3.

    Then, when you want to activate these sounds:

    on(press) {

    And if you need to stop a sound for some reason:


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