You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
446 B
26 lines
446 B
15 years ago
|
# This is a simple example of using the builtin object timer
|
||
|
# capabilities.
|
||
|
|
||
|
# we create a new object
|
||
|
%bomb = $new(object,0,myobject)
|
||
|
|
||
|
# implement its timerEvent
|
||
|
privateimpl(%bomb,timerEvent)
|
||
|
{
|
||
|
if($$->%secsToGo > 0)
|
||
|
{
|
||
|
echo "Countdown: $$->%secsToGo"
|
||
|
$$->%secsToGo--;
|
||
|
} else {
|
||
|
echo "Boom!"
|
||
|
delete $this
|
||
|
}
|
||
|
}
|
||
|
|
||
|
# and trigger it
|
||
|
echo "Countdown: 10 seconds to go"
|
||
|
%bomb->%secsToGo = 9
|
||
|
%bomb->$startTimer(1000)
|
||
|
|
||
|
# now just have to wait...
|