28-07-2009

Actionscript3 Fade out function AS3

This function fades out the current stage by drawing a filled rectangle on top of it and tweening the alpha. Can be used for modal by adding a child on top of it.

function fadeOut(color:uint = 0xFFFFFF){
	square = new Shape();
	square.graphics.beginFill(color);
	square.graphics.drawRect(0, 0, this.stage.stageWidth, this.stage.stageHeight);
	square.graphics.endFill();
	this.addChild(square);
	var t = new Tween(square, "alpha", Regular.easeIn, 0.1, 0.8, 2, true);
	t.addEventListener(TweenEvent.MOTION_FINISH, function(e:TweenEvent){
			//trace(e.currentTarget.obj);		
	});
}
 

Comments:

Your comment:

»
Zermok 31/07/2010, 4:13 am
great exemple, thank you !

 

[x]