| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Member
Join Date: Sep 2007
Posts: 71
|
Ok, I knew how to do this in AS2, when I did a search in this site for this topic..all that came up was as2 tuts...
I already have my streaming audio initialized using: Code:
var sAmbience:Sound = new Sound();
sAmbience.load(new URLRequest("ambience.mp3"));
var sAmbienceVol:SoundTransform = new SoundTransform(1, 0);
Any ideas? Thank youi -D |
|
|
|
|
|
#2 |
|
Senior Member
|
Run a tween, and on each tween update, turn the volume down by the tweened volume amount?
__________________
the beers just sit there, silently staring, and mocking the mistakes my animal mind makes sometimes - Spyre |
|
|
|
|
|
|
|
|
#3 |
|
Member
Join Date: Sep 2007
Posts: 71
|
Rossman,
That is an interesting idea, but a tween has only so many arguments, where would I place the sound decrement? How would I syntax it? |
|
|
|
|
|
#4 |
|
What's up pussycat?
|
For something as simple as a single number decrement, it'd be easy just to use a Timer. Look up the Timer class in the documentation, it isn't hard to set up.
One thing, when you want to turn off your timer, make sure you don't define the Timer i.e. var volumeTimer:Timer = new Timer(100, 10); from inside any functions. Otherwise you won't be able to turn it off!
__________________
http://matbury.com/ |
|
|
|
|
|
#5 |
|
Member
Join Date: Sep 2007
Posts: 71
|
Mat,
Thank you for your response. I already know how to set up a timer object and have it run a function. It is the "looping" aspect that has got me confused. here is my timer: Code:
var soundFadeInTimer:Timer = new Timer(1000,1);
soundFadeInTimer.addEventListener("timer", soundFadeIn);
soundFadeInTimer.start()
// now for the function//
function soundFadeIn(e:TimerEvent){
this is where I need help
}
Thanks again -D |
|
|
|
|
|
#6 |
|
Senior Member
|
In this line:
ActionScript Code:
You need to increase the number of times the timer will execute, ie: ActionScript Code:
(I've also decreased the timing, as well) Now it will run 30 times, and you can reduce the volume by 1/30 each time the listener fires. Like: ActionScript Code:
That probably won't actually work, but should give you then idea...
__________________
the beers just sit there, silently staring, and mocking the mistakes my animal mind makes sometimes - Spyre Last edited by Rossman; 11-03-2007 at 03:53 AM.. |
|
|
|
|
|
#7 |
|
Member
Join Date: Sep 2007
Posts: 71
|
Thank you Ross:
It doesn't quite work yet, but here is my code: Code:
var soundFadeInTimer:Timer = new Timer(100,30);
soundFadeInTimer.addEventListener("timer", soundFadeIn);
soundFadeInTimer.start()
var fadeInIncr:Number = 0.1;
function soundFadeIn(e:TimerEvent){
fadeInIncr += 1/30;
var sAmbienceVol:SoundTransform = new SoundTransform(fadeInIncr, 0);
trace(fadeInIncr)
}
sAmbience.play(0,20,sAmbienceVol)
Here is the output per trace: 0.13333333333333333 0.16666666666666666 0.19999999999999998 0.2333333333333333 0.26666666666666666 0.3 0.3333333333333333 0.36666666666666664 0.39999999999999997 0.4333333333333333 0.4666666666666666 0.49999999999999994 0.5333333333333333 0.5666666666666667 0.6 0.6333333333333333 0.6666666666666666 0.7 0.7333333333333333 0.7666666666666666 0.7999999999999999 0.8333333333333333 0.8666666666666666 0.8999999999999999 0.9333333333333332 0.9666666666666666 0.9999999999999999 1.0333333333333332 1.0666666666666667 1.1 So we can see that the counter is working, but my volume is not increasing. Any ideas? |
|
|
|
|
|
#8 |
|
Member
Join Date: Sep 2007
Posts: 71
|
Ok, Here is my latest code:
Code:
var soundFadeInTimer:Timer = new Timer(100,30);
soundFadeInTimer.addEventListener("timer", soundFadeIn);
soundFadeInTimer.start()
var fadeInIncr = 0.1;
function soundFadeIn(e:TimerEvent){
fadeInIncr += 1/30;
trace(fadeInIncr)
}
var snd:Sound = new Sound(new URLRequest("myLoop.mp3"));
var trans:SoundTransform = new SoundTransform(fadeInIncr, 0); // 1=vol, 0=pan
var channel:SoundChannel = snd.play(0, 1, trans);
Trace Output: 0.13333333333333333 0.16666666666666666 0.19999999999999998 0.2333333333333333 0.26666666666666666 0.3 0.3333333333333333 0.36666666666666664 0.39999999999999997 0.4333333333333333 0.4666666666666666 0.49999999999999994 0.5333333333333333 0.5666666666666667 0.6 0.6333333333333333 0.6666666666666666 0.7 0.7333333333333333 0.7666666666666666 0.7999999999999999 0.8333333333333333 0.8666666666666666 0.8999999999999999 0.9333333333333332 0.9666666666666666 0.9999999999999999 1.0333333333333332 1.0666666666666667 1.1 0.13333333333333333 0.16666666666666666 0.19999999999999998 0.2333333333333333 0.26666666666666666 0.3 0.3333333333333333 0.36666666666666664 0.39999999999999997 0.4333333333333333 0.4666666666666666 0.49999999999999994 0.5333333333333333 0.5666666666666667 0.6 0.6333333333333333 0.6666666666666666 0.7 0.7333333333333333 0.7666666666666666 0.7999999999999999 0.8333333333333333 0.8666666666666666 0.8999999999999999 0.9333333333333332 0.9666666666666666 0.9999999999999999 1.0333333333333332 1.0666666666666667 1.1 The sound does not fade in. Any Ideas?? Last edited by seven; 11-03-2007 at 09:29 AM.. Reason: added info |
|
|
|
|
|
#9 |
|
Senior Member
|
You aren't assigning the SoundTransform to your SoundChannel object?
ie: ActionScript Code:
__________________
the beers just sit there, silently staring, and mocking the mistakes my animal mind makes sometimes - Spyre |
|
|
|
|
|
#10 |
|
Member
Join Date: Sep 2007
Posts: 71
|
Thanks Ross! That worked
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Dynamic Sound Fading | greenpear | ActionScript 2.0 | 3 | 10-26-2007 02:38 PM |
| Kenny Bellew Sound Object Tutorial Updated | Kennyb | ActionScript 2.0 | 23 | 05-09-2007 09:38 PM |
| [stuff] as3 sound visualising efx | arrFoo | ActionScript 3.0 | 0 | 02-01-2007 10:53 AM |
| [F8] Fading out specific sound while keeping others active | Trinidad | ActionScript 2.0 | 2 | 07-14-2006 06:26 PM |
| Control Sound Object | puthisorn | ActionScript 2.0 | 9 | 05-06-2004 05:20 AM |