Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7586915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:32:42+00:00 2026-05-30T19:32:42+00:00

In my case, the timer I make doesn’t reduce its time whenever a function

  • 0

In my case, the timer I make doesn’t reduce its time whenever a function is called. What code will I change or add in order to reduce the time in my timer?

Timer code:

var count:Number = 1200;
var lessTime:Number = 180;
var totalSecondsLeft:Number = 0;
var timer:Timer = new Timer(1000, count);
timer.addEventListener(TimerEvent.TIMER, countdown);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, timesup);

function countdown(event:TimerEvent) {
    totalSecondsLeft = count - timer.currentCount;
    this.mainmc.time_txt.text = timeFormat(totalSecondsLeft);
}

function timeFormat(seconds:int):String {
var minutes:int;
var sMinutes:String;
var sSeconds:String;
if(seconds > 59) {
    minutes = Math.floor(seconds / 60);
    sMinutes = String(minutes);
    sSeconds = String(seconds % 60);
    } else {
    sMinutes = "";
    sSeconds = String(seconds);
}
if(sSeconds.length == 1) {
    sSeconds = "0" + sSeconds;
}
return sMinutes + ":" + sSeconds;
}

function timesup(e:TimerEvent):void {
    gotoAndPlay(14);
}

At this point the timer.start(); is placed on a frame so that the timer starts as it enters the frame.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T19:32:43+00:00Added an answer on May 30, 2026 at 7:32 pm

    The delay property on Timer is what you are looking for. In your handler, change the timer’s delay:

    function countdown(event:TimerEvent)
    {
        totalSecondsLeft = count - timer.currentCount;
        this.mainmc.time_txt.text = timeFormat(totalSecondsLeft);
    
        //change the timer delay
        timer.delay -= lessTime;
    }
    

    I assumed by your code sample that you wanted to subtract lessTime from the timer delay on each timer interval. If you want to change the delay to something else, then just adjust the code accordingly.

    UPDATE
    The above code is for decreasing the interval (delay) between each timer fire. If what you’d like to do instead is decrease the the amount of intervals (repeatCount) it takes for the timer to reach TIMER_COMPLETE, then you want to change the repeatCount property on Timer:

    //set the timer fire interval to 1 second (1000 milliseconds)
    //and the total timer time to 1200 seconds (1200 repeatCount)
    var timer:Timer = new Timer(1000, 1200);
    
    //reduce the overall timer length by 3 minutes
    timer.repeatCount -= 300;
    

    ANOTHER UPDATE
    Keep in mind that when you alter the repeatCount, it doesn’t affect the currentCount. Since you are using a separate count variable and timer.currentCount to calculate the displayed time remaining, it doesn’t look like anything is changing. It actually is though – the timer will complete before the displayed time counts down to zero. To keep your time left display accurate, make sure to subtract the same amount from count as you are from repeatCount:

    timer.repeatCount -= 300;
    count -= 300;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

every time i code a gui (in my case with GWT, never touched gui
Every time I do anything, and my while(1) gets called in my main function,
I want get the time used for a case so I can create an
case i of 0..99 : Function-call('bobo') ; 100..209 : function-smell('Hobo'); 210..300 : function-yikes('argh'); end;
The title probably doesn't make much sense, so I'll try to be descriptive here
I'm triying to make a 2D real-time plot. I've tried with modifying the osciloscope
Is it required for me to add a _REENTRANT macro during compile time to
I have this code. I don't know why postDelay make UI frozen in this
Yes, the title doesn't make much sense, but here's my situation. I have two
Given the following code: bool doGoodThing; switch (some_variable) { case 1: case 2: doGoodThing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.