package classes.gustavo.midia
{
	import classes.fl.motion.easing.Bounce;
	import classes.fl.motion.easing.Exponential;
	import classes.fl.motion.easing.Quintic;
	import classes.greensock.TweenMax;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.filters.BlurFilter;
	import flash.utils.Timer;
	import flash.utils.setTimeout;
	
	public class TimerCount extends MovieClip
	{
		
		private var timer	:Timer;
		private var current	:int = 1;
		
		public function TimerCount()
		{
			stop();
			
			alpha  =  0;
			y      = y + 30;
			filters = [new BlurFilter(0,30)]
						
		}
		
		public function init(_segundos:int):void
		{  
			TweenMax.to(this,1.3,{autoAlpha:1,y:y-30,blurFilter:{blurY:0},ease:Exponential.easeInOut});

			setTimeout(function():void
			{
				timer = new Timer(1200,_segundos);
				timer.addEventListener(TimerEvent.TIMER,onTimer);
				timer.addEventListener(TimerEvent.TIMER_COMPLETE,onTimerComplete);
				timer.start();
			
			},1300);
		}
		
		private function onTimer(e:TimerEvent):void
		{
			TweenMax.to(this,.5,{frame:current*20,ease:Bounce.easeInOut});
			current++;
		}
		
		private function onTimerComplete(e:TimerEvent):void
		{
			TweenMax.to(this,1.1,{autoAlpha:0,y:y+30,blurFilter:{blurY:50},frame:0,ease:Exponential.easeInOut});
			dispatchEvent(new Event(Event.COMPLETE));
		}
	
		
	}//end class
}