Alex Rivera | Logout

Sounds fade in/out with ActionScript 3

Asked 2010-10-06T13:11:59.293
9

I am trying to make a fade in/out in a music in a Flash (CS5) project. I imported the sound to library, set a classname for "Export for ActionScript", and I was trying to fade with TweenLite/TweenMax, like this:

var sound = new MySound();
sT = new SoundTransform(0.1);
sound.play(0,99999, c_sndEnvironment);
TweenLite.to(sound, 1, {volume: 1.0});

But it just doesn't work. I tried to import the volume plugin on TweenLite, and still nothing. I got no error at all though.

Am I doing anything wrong?

Plus, is there any good (complete) AS3 library for music?

Thank you. :)

Edit
Report

1 Answer

1

sorry, I kind kind of a strange behaviour from these lines of code. My sound fades out, and yoyos back. after the soundchannel is at the same volume as before, onComplete is executed normally. Any ideas?

themeChannel = sndTheme.play(0, 99999); TweenLite.from(themeChannel, 2, {volume:0,onComplete:stopTheme});

//edit: I got it working by Tweening a SoundTransform Object:

var themeTransform:SoundTransform = new SoundTransform(1);
themeChannel  = sndTheme.play(0, 99999, themeTransform);
TweenLite.from(themeTransform, 3, {volume:0,onUpdate:updateSound,onComplete:stopTheme});

function updateSound():void{
           themeChannel.soundTransform = themeTransform;
        }

thanks to: http://www.zedia.net/2008/fading-out-volume-using-tweenlite/

answered 2013-02-19T14:27:41.043

Your Answer