for statement to turn down sound volume
Hi all,
I used this (snippet)
PHP Code:
for ( a = 0 , a > 100 , a ++); 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?
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
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
Last edited by rickus2009; 04-17-2009 at 01:48 AM .
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
Forum Rules
Click Here to Expand Forum to Full Width