Timer Countdown Bar Script

Hi all,

I have a script below which counts down and using the progress info makes a movieclip widen from nothing to its full width using the x scale.

This is being used for a countdown bar in my game so at the moment this bar movieclip is growing from nothing to its normal size. I want to reverse this so It starts at its normal size and grows smaller if you see what I mean.

A little example would be awesome :smiley:

(AS3)

Thanks

The script exists within 3 AS files,

Code in GameLevel.as:



var timer:ProgressTimer = new ProgressTimer(); 
			timer.addEventListener( ProgressTimerEvent.PROGRESS, onProgress ); 
			timer.start( 15000 ); 

			function onProgress( e:ProgressTimerEvent ):void 
			{ 
				trace( e.progress ); 
				 
				seismo.scaleX = e.progress;
				
			} 

Code in ProgressTimer.as:



package 
{ 
    import ProgressTimerEvent; 
     
    import flash.events.Event; 
    import flash.events.EventDispatcher; 
    import flash.utils.clearInterval; 
    import flash.utils.getTimer; 
    import flash.utils.setInterval; 
     
    public class ProgressTimer extends EventDispatcher 
    { 
        private var startTime:int = 0; 
        private var targetTime:int = 0; 
        private var interval:int = 0; 
        private var isRunning:Boolean = false; 
         
        public function ProgressTimer() 
        {} 
         
        public function start( time:int ):void 
        { 
            stop(); 
             
            startTime  = getTimer(); 
            targetTime = startTime + time; 
            interval   = setInterval( update, 30); 
            isRunning  = true; 
        } 
         
        public function stop():void 
        { 
            if( isRunning ) 
            { 
                clearInterval( interval ); 
                isRunning = false; 
            } 
        } 
         
        private function update():void 
        { 
            var p:Number = getTimer() / targetTime; 
             
            if( p >= 1.0 ) 
            { 
                p = 1.0; 
                stop(); 
            } 
             
            var t:String = ProgressTimerEvent.PROGRESS; 
            dispatchEvent( new ProgressTimerEvent( t, p ) ); 
        } 
         
    } 
} 

and finaly from ProgressTimerEvent:



package 
{ 
    import flash.events.Event; 
     
    public class ProgressTimerEvent extends Event 
    { 
        public static const PROGRESS:String = "progress"; 
         
        private var _progress:Number = 0; 
         
        public function ProgressTimerEvent( type:String, progress:Number )
        { 
            super( type, false, false ); 
            _progress = progress; 
        } 
         
        public function get progress():Number // read-only 
        { 
            return _progress; 
        } 
    } 
} 


If anyone knows how to do this, your awesome.

Thanks!