XWidgetSoft Forum

XWidget & XLaunchpad , Desktop customization
It is currently May 9th, 2025, 1:45 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: setInterval Function
PostPosted: September 10th, 2012, 11:16 pm 
Offline
User avatar

Joined: August 29th, 2012, 2:34 am
Posts: 56
i can't get the function work. Could somebody show me an working example of the setInterval(name,time); function?

_________________
Image


Top
 Profile  
 
 Post subject: Re: setInterval Function
PostPosted: September 11th, 2012, 3:00 am 
Offline
User avatar

Joined: June 10th, 2012, 5:57 am
Posts: 313
hi , vlad setInterval function is not available in XWidget , you can use a timerCore to replace it


Top
 Profile  
 
 Post subject: Re: setInterval Function
PostPosted: September 11th, 2012, 4:34 am 
Offline
User avatar

Joined: August 29th, 2012, 2:34 am
Posts: 56
It's cool man, i had figured it out.

Just use setTimeout function like this
Code:

// ms = 1000 / fps
// 1000 / 40(fps) = 25(ms)
var timeMs = 25;

setTimeout("moveButton",timeMs);

function moveButton()
{
      displayAnimation();
      setTimeout("moveButton",timeMs);
}


And i even managed to play / stop animation on click. 8-)

Code:

var timeMs = 25;
start();

function moveButton()
{
      if ( ! looping ) return;

      displayAnimation();

      setTimeout("moveButton",timeMs);
}

function start()
{
      if ( looping ) return;
      setTimeout("moveButton",timeMs);
      looping = true;
}

function stop()
{
      if ( ! looping ) return;
      looping = false;
}


_________________
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 32 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB® Forum Software © phpBB Group