XWidgetSoft Forum

XWidget & XLaunchpad , Desktop customization
It is currently 2017年 Nov 24日 21:33

All times are UTC - 8 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: setInterval Function
PostPosted: 2012年 Sep 10日 23:16 
Offline
User avatar

Joined: 2012年 Aug 29日 02:34
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: 2012年 Sep 11日 03:00 
Offline
User avatar

Joined: 2012年 Jun 10日 05:57
Posts: 315
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: 2012年 Sep 11日 04:34 
Offline
User avatar

Joined: 2012年 Aug 29日 02:34
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 8 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