Stop a Timer

Hi, could you please help me with this? I have a button to start a timer changing the running attribute, but I want to stop the timer when reach 100, I have this on the button but it doesn’t work.

value = 1
value2 = 0
event.source.parent.getComponent(‘Timer’).running = value

if event.source.parent.getComponent(‘Timer’).value == 100 :
event.source.parent.getComponent(‘Timer’).running = value2


Put this code in your Button actionPerformed event script:

event.source.parent.getComponent('Timer').running = True

Put this code in your Timer propertyChange event script:

if event.propertyName == "value":
    if event.newValue == 100:
        event.source.running = False

Make sure the Bound property of the Timer component has a value greater than 100.


I appreciate your help. Thanks a lot.

1 Like