How can you access the same instance of a timer in a class, in order to stop and delete it?
The following will start the timer, but can't stop it. I have tried all variations I can think of, including attempting to make the function object a class variable.
Code: Select all
#SingleInstance Force
#Persistent
myTimer1 := new MyTimer()
myTimer1.Play()
Sleep, 2000
myTimer.Stop()
return
class MyTimer
{
count := 0
Play()
{
fn := this._Play.Bind(this)
SetTimer, % fn, 500
}
Stop()
{
fn := this._Play.Bind(this)
SetTimer, % fn, Delete
}
_Play()
{
this.count++
Tooltip % this.count
}
}