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 6855489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:45:54+00:00 2026-05-27T01:45:54+00:00

Possible Duplicate: function in setInterval() executes without delay I am trying to use setTimeOut

  • 0

Possible Duplicate:
function in setInterval() executes without delay

I am trying to use setTimeOut to calla function every X milliseconds, but it seems that it just freaks out and counts incredibly fast no matter what timeframe I set it to? Am I doing something wrong?

var Count = 0;
var GameRunning = 0;

var lblTimer = Titanium.UI.createLabel({
    color:'#999',
    text:'I am Window 1',
    font:{fontSize:20,fontFamily:'Helvetica Neue'},
    textAlign:'center',
    width:'auto',
    height: 25,
    top: 25
});

var btnStartGame = Titanium.UI.createButton({
   title: 'Start',
   width: 50,
   height: 25,
   top: 75
});

function RunGame () {
  Count++;
  lblTimer.text = Count;
  x = setTimeout(RunGame(), 100000);
}

function StartGame () {
  if(GameRunning==0)
  {
    GameRunning = 1;
    RunGame();
  }
    else
  {
    // Stop the game.
    GameRunning = 0;
    Count = 0;
  }
}

function GameTimerCount() {
    Titanium.API.info("inside GameTimerCount");
    Count++;
    lblTimer.text = "RUNNING: " + Count;
}

btnStartGame.addEventListener('click',function(e)
{
    Titanium.API.info("button clicked");
    StartGame();

    //var test = setInterval("GameTimerCount()",100);
});

// Add objects to window
Titanium.UI.currentWindow.add(lblTimer);
Titanium.UI.currentWindow.add(btnStartGame);
  • 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-27T01:45:55+00:00Added an answer on May 27, 2026 at 1:45 am

    Change your setTimeout call to this:

    setTimeout(RunGame,1000);
    

    RunGame() returns void so having setTimeout(RunGame(),1000); is actually more akin to setTimeout(void,1000); which does nothing. setTimeout works by using a function pointer to know what function to execute.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Chaining a function in JavaScript? I asked a similar question , but
Possible Duplicate: problem sorting using member function as comparator Is it possible to use
Possible Duplicate: $(document).ready equivalent without jQuery I know you can use the window.onload event
Possible Duplicate: php mail() function on localhost I'm trying to do some localhost testing
Possible Duplicate: how to apply a function to every row of a matrix (or
Possible Duplicate: Use a variable to define a PHP function Is there a way
Possible Duplicate: JavaScript Function Definition in ASP User Control Hi, I have a generic
Possible Duplicate: Faster DirectoryExists function? I want to check if some file exists on
Possible Duplicate: JavaScript: var functionName = function() {} vs function functionName() {} What's the
Possible Duplicate: JavaScript: Why the anonymous function wrapper? I would like to ask you

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.