A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Time manipulation

  1. #1
    Senior Member
    Join Date
    Jan 2001
    Location
    UK
    Posts
    149

    Time manipulation

    Hi,

    I am trying to implement a timeout function for my application. I have a time string that I import in the format "00:05:00" (C# - representing a 5 minute timeout).
    I am trying to run a timer that runs every second or so and calculates when the timeout has been reached.
    I could just compare the minutes but it could be "01:05:20" for example. Is there an easy way to achieve this?

    There doesn't seem to be many time manipulation functions available

    Any help would be appreciated

    Thanks

  2. #2
    Senior Member
    Join Date
    Jan 2001
    Location
    UK
    Posts
    149
    Ok, I got it, bodged it a bit by calculating the total number of seconds to use:

    Code:
    		public function TimeoutTimerFired(event:TimerEvent):void 
    		{
    			var now:Date = new Date();
    			var diff:Date = new Date();
    			
    			diff.time = (now.time - TimeStarted.time);
    			
    			if(GetTotalSeconds(diff) > GetTotalSeconds(Timeout))
    				 trace("Timeout!");
    		}
    		
    		function GetTotalSeconds(d:Date):int
    		{
    			var secs:int;
    			
    			secs = d.seconds;
    			secs += d.minutes * 60;
    			secs += (d.hours * 60) * 60;
    			
    			return secs;
    		}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center