Old 10th August 2005, 15:11   #1
JW
Senior Member
 
Join Date: Nov 2004
Location: Valencia, CA
Posts: 304
Timer Syntax

I know how to use a timer to make an action happen for a certain amount of time. How do I use one to make an action happen after a specified time?
JW is offline   Reply With Quote
Old 10th August 2005, 23:34   #2
krckoorascic
Senior Member
 
krckoorascic's Avatar
 
Join Date: May 2004
Location: Serbia
Posts: 351
Send a message via ICQ to krckoorascic Send a message via AIM to krckoorascic Send a message via Yahoo to krckoorascic
well, it's the same thing

code:

Global Timer myTimer;

System.onScriptLoaded()
{
myTimer = new Timer;
myTimer.setDelay(100);
myTimer.start();
}

System.onScriptUnloading()
{
delete myTimer;
}

myTimer.onTimer()
{
//do what you want
myTimer.stop(); //stop it if you don't need anymore
}



krckoorascic is offline   Reply With Quote
Old 11th August 2005, 13:56   #3
JW
Senior Member
 
Join Date: Nov 2004
Location: Valencia, CA
Posts: 304
That's kinda what I thought, too, but it's not working.

Here's what I'm trying to do - I wrote a script, with a lot of help (naturally ) that will automatically switch to my shade layout when Winamp becomes inactive. But, I'd like there to be a bit of a delay before it switches layouts (for cases where Winamp is very briefly inactive - no need to have it switch layouts, only to have it immediately switch back).

PHP Code:
System.onScriptLoaded()
{
//A bunch of other crap here...
  
toggleTimer = new Timer;
  
toggleTimer.setDelay(3000);
  
toggleTimer.start();
}

toggleTimer.onTimer()
{
  
goShade();
}

onWinampinActive(){
  if (
System.getPrivateInt("Mobile PC""AutoShade"1) == 1)
  {
    
goShade();
    
toggleTimer.stop();
  }

JW is offline   Reply With Quote
Old 12th August 2005, 03:05   #4
gbr
Senior Member
 
Join Date: Nov 2004
Location: Mumbai ( Bombay ), India
Posts: 143
Shouldn't the logic be something like :

toggleTimer.onTimer()
{
if ( not isAppActive() && not already in shade mode )
{
if (System.getPrivateInt("Mobile PC", "AutoShade", 1) == 1)

goShade();

}
}


Stop the timer on script unload.
gbr is offline   Reply With Quote
Old 12th August 2005, 03:14   #5
gbr
Senior Member
 
Join Date: Nov 2004
Location: Mumbai ( Bombay ), India
Posts: 143
You could also start the timer if / when the privateint is set to not 1 .
gbr is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Skinning and Design > Modern Skins

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump