A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: for statement to turn down sound volume

  1. #1
    Junior Member
    Join Date
    Apr 2009
    Posts
    3

    for statement to turn down sound volume

    Hi all,

    I used this (snippet)

    PHP Code:
    for (a=0a>100a++); or
    for (
    a=100. a<1. a--);
    setVol(a
    to increase/decrease volume of a sound file by clicking on a button.

    It is working in the debug screen and it is working with the actual sound file. But instead of fading in or out, it just goes straight from 0-100 or 100-0 instantly. Is there a way to put a time delay between the counts?

  2. #2
    Junior Member
    Join Date
    Dec 2004
    Posts
    7
    I don't think that you can use a for statement like that, as it executes it all at once..basically..as you found.

    Here is one way that you can use a button to fade vol up or down;
    on vol up button:

    Code:
    on (press) {
        onEnterFrame= function(){
            myVol++;       // change to  "myVol--;" on vol dn btn
            mySound.setVolume(myVol);
            if(myVol>=100){         // change to  "if(myVol<=0){" on vol dn btn
                delete onEnterFrame;
            }
            trace(myVol)
        }
    }
    on (release,releaseOutside) {
        delete onEnterFrame
    }
    good luck

    aaron

  3. #3
    Junior Member
    Join Date
    Apr 2009
    Posts
    3

    Sound fade in and out with 1 button

    Hi browndrake,

    Thanks for your help - much appreciated. I couldn't get yours to work and so modified it a bit and it is working great now.

    Thanks again!!

    You can just add a longer audio file to it as I had to remove the original audio file to be less than 300kb.
    Attached Files Attached Files
    Last edited by rickus2009; 04-17-2009 at 01:48 AM.

  4. #4
    Junior Member
    Join Date
    Dec 2004
    Posts
    7
    glad you got it working.

    just a note: You have to extra closing braces at the end of frames 2 and 10

    good luck

    aaron

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