To change the colour of a timer, you just need to call ogscript.setStyle on the label that is being used for display. Here is an example of a timer that changes from green to red when it goes from positive to negative.
The important code is in the timer's task where we check the current value and set the colour accordingly.
<abs contexttype="opengear" style="">
<meta>
<params>
<param access="1" maxlength="0" name="game-timer-display" oid="gametimerdisplay" stateless="true" type="STRING" value="00:00" widget="label"/>
</params>
</meta>
<timer autostart="false" id="game-timer" pattern="mm:ss" rate="500" start="00:05" stop="-00:05">
<timertask tasktype="ogparamset">params.setValue('gametimerdisplay', 0, event.getDisplay());
if (event.getCurrentValue() > 0)
{
ogscript.setStyle('timer-display', 'fg#00FF00');
}
else if (event.getCurrentValue() <= 0)
{
ogscript.setStyle('timer-display', 'fg#FF0000');
}
</timertask>
</timer>
<param expand="true" height="104" id="timer-display" left="17" oid="gametimerdisplay" style="style:timerLabel;" top="20" width="443"/>
<button buttontype="push" height="94" left="467" name="Start/Pause" top="23" width="125">
<task tasktype="ogscript">var timer = ogscript.getTimerManager().getTimer("game-timer");
if (!timer.isRunning())
{
timer.startTimer(false);
}
else
{
timer.stopTimer(false);
}
</task>
</button>
</abs>#DashBoard