Jump to content
GreenSock

Applauz

TweenMax Sound Bug Driving Me Crazy[HELP]

Recommended Posts

This is driving me absolutely crazy.  Trying to do a simple task of fading in a sound. I am able to do it when the TweenMax call is done outside of a function. However if the call is in a function it doesnt work.

 

The following code does not work... even placing trace statements in the checkDoorStatus, etc to verify the function gets called.

var introDoor:Sound = new DoorOpenClose();
var soundTrans:SoundTransform = new SoundTransform(0,0);
var soundChannel:SoundChannel = introDoor.play(0,0,soundTrans);



function checkDoorStatus():void{
	
	
	
	if(doorLeft_mc.x < -300 && doorRight_mc.x > 750){
	
		
		killAllDoorListeners();
	
		TweenMax.to(doorLeft_mc, 4, {x:-554, ease:Expo.easeOut, onComplete:cleanUpDoors});
		TweenMax.to(doorRight_mc, 4, {x:1024, ease:Expo.easeOut});
		TweenMax.to(fade_mc, 2, {alpha:0, ease:Expo.easeOut});
		TweenMax.to(doorFrame_mc, 1, {alpha:0, delay:0.2, ease:Expo.easeOut, onComplete:killFrame});
		
		
		TweenMax.to(soundChannel, 2, { volume:1, ease:Strong.easeInOut, onUpdate:fadeDoorSound } );
		
	}
}



function fadeDoorSound():void{
	trace("SOUND SHOULD BE FADING");
	 var soundTrans : SoundTransform = new SoundTransform(soundChannel.soundTransform.volume, 0 );
     soundChannel.soundTransform = soundTrans;
}

This however does work...  but is no good to me as I need the TweenMax to get called inside the checkDoorStatus function.

var introDoor:Sound = new DoorOpenClose();
var soundTrans:SoundTransform = new SoundTransform(0,0);
var soundChannel:SoundChannel = introDoor.play(0,0,soundTrans);


TweenMax.to(soundChannel, 2, { volume:1, ease:Strong.easeInOut, onUpdate:fadeDoorSound } );


function fadeDoorSound():void{
	trace("SOUND SHOULD BE FADING");
	 var soundTrans : SoundTransform = new SoundTransform(soundChannel.soundTransform.volume, 0 );
     soundChannel.soundTransform = soundTrans;
}

Any idea why this would be happening ?

 

 

 

Link to comment
Share on other sites

I'm kind of confused here.

Doesn't the VolumePlugin fade the sound fine without the need of an onUpdate?

http://api.greensock.com/as/com/greensock/plugins/VolumePlugin.html

 

Are you sure you activated it?

 

Sorry, but I'm really not following what is happening in your onUpdate with the new SoundTransforms being created and such.

 

Perhaps a little more info would help.

 

for reference here are some files that use the VolumePlugin:

http://api.greensock.com/as/com/greensock/plugins/VolumePlugin.html

 

Fading a sound is fairly straight-forward.

Link to comment
Share on other sites

I've tried without the update option as well... 

 

Even this wont work


var snd:Sound = new DoorOpenClose();
var channel:SoundChannel = snd.play(0);




function checkDoorStatus():void{
	
	
	if(doorLeft_mc.x < -300 && doorRight_mc.x > 750 && doorStatusNum == 1){
		
		
		TweenLite.to(channel, 2, {volume:1});
		

		TweenMax.to(doorLeft_mc, 4, {x:-554, ease:Expo.easeOut, onComplete:cleanUpDoors});
		TweenMax.to(doorRight_mc, 4, {x:1024, ease:Expo.easeOut});
		TweenMax.to(fade_mc, 2, {alpha:0, ease:Expo.easeOut});
		TweenMax.to(doorFrame_mc, 1, {alpha:0, delay:0.2, ease:Expo.easeOut, onComplete:killFrame});
		

}
Link to comment
Share on other sites

it wont let me Tween the channel variable from inside a function.

 

If I put  

 

var snd:Sound = new DoorOpenClose();
var channel:SoundChannel = snd.play(0);
 

TweenLite.to(channel, 2, {volume:1});

 

 

This will work however I need it in the function.

Link to comment
Share on other sites

I just did a simple test of doing a volume tween from within a function. No problems.

 

Try the files provided here: http://www.snorkl.tv/2011/07/easy-as3-toggle-and-fade-sound-with-tweenlite-volume-plugin/

 

var sound:Sound = new chicken();
var soundChannel:SoundChannel = new SoundChannel()
var soundTrans:SoundTransform = new SoundTransform(0);
soundChannel = sound.play(0,9999, soundTrans)




var soundOn:Boolean = false;


stage.addEventListener(MouseEvent.CLICK, toggleSound);


function toggleSound(e:MouseEvent):void{
soundOn = ! soundOn
TweenLite.to(soundChannel, 2, {volume:int(soundOn)});
sound_mc.gotoAndStop(int(soundOn)+1);
}

If you want to post a very simple file that contains just enough code and assets to replicate the problem we will take a look.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×