[Closed] Timer doubt
how can i make a messagebox appear when the timer reaches 3 second:
rollout timers "Timer"
(
timer clock "testClock" interval:1000
label test "1"
on clock tick do
(
valUp = (test.text as integer)+1
test.text = valUp as string
)
)
createdialog timers
- using dotnet “Timer”
- showing the dialog out of screen first and moving it to right place after.
here is how to use MXS and .NET timers:
try(destroydialog stopRol) catch()
rollout stopRol "Timers" width:200
(
local delay = 2000.0
button mxs_timer_bt "Start MXS Timer" width:190
button net_timer_bt "Start .NET Timer" width:190
local net_tm = dotnetobject "Timer"
timer mxs_tm interval:delay active:off
on mxs_tm tick do
(
mxs_tm.ticks = 0
mxs_tm.active = off
act = queryBox ((delay/1000) as string + "s left. Do you want to continue?") title:"MXS Timer" beep:off
if act do mxs_tm.active = on
)
fn onTick s a =
(
s.Stop()
act = queryBox ((delay/1000) as string + "s left. Do you want to continue?") title:".NET Timer" beep:off
if act do s.Start()
)
on mxs_timer_bt pressed do
(
mxs_tm.ticks = 0
mxs_tm.active = on
)
on net_timer_bt pressed do
(
net_tm.Start()
)
on stopRol close do net_tm.dispose()
on stopRol open do
(
net_tm.Interval = delay
dotnet.addEventHandler net_tm "Tick" onTick
)
)
createdialog stopRol
Thanks denist…i dont know how to use dotnet in maxscript…do you know any basic tutorials on the net about dotnet and Maxscript
ops… I read the original post carelessly.
how can i make a messagebox appear when the timer reaches 3 second:
Do you want to interrupt the second process showing a modal messagebox after some delay?
Hmmm… this might work, haven’t tried it.
rollout timers “Timer”
(
timer clock “testClock” interval:1000
label test “0”
on clock tick do
(
valUp = (test.text as integer)+1
test.text = valUp as string
if test.text == “3” then messagebox “popup”
)
)
createdialog timers
If you want to keep the interval at 1000ms, and you don’t want to use a .net timer, you can do two things:
-use a second timer with an interval of 3000ms
-use a local variable on the rollout which tracks the ticks of the 1000ms timer. (that’s much more elegant than using a label to keep the count!)