mattlundstrom
8/5/2012 - 2:22 AM

AS3 TweenMax Fade Between Sections of a Site

AS3 TweenMax Fade Between Sections of a Site

// USEAGE 
// transitionTo(myMC);

var currentSection:MovieClip;
var nextSection:MovieClip;

function transitionTo(_nextSection:MovieClip):void
{
	nextSection = _nextSection
	
	currentSection ? fadeOut() : fadeIn();
	
	function fadeOut():void
	{
		TweenMax.to(currentSection, .5, {autoAlpha:0, onComplete:fadeIn});
	}

	function fadeIn():void
	{
		TweenMax.to(nextSection, .5, {autoAlpha:1, onComplete:swap});
	}
	
	function swap():void
	{
		currentSection = nextSection
	}
}