'MAIN LOOP
While 0=0
If buttonClicked Then
If Controls.LastClickedButton = targetControl Then
startAnimate = Clock.ElapsedMilliseconds
Shapes.Animate(sprite, Shapes.GetLeft(target), Shapes.GetTop(target), 2000)
Sound.PlayChimes()
EndIf
buttonClicked = "False" 'Once processed - ready for another buttonClick
EndIf
If startAnimate <> "" And Clock.ElapsedMilliseconds - startAnimate > 2000 Then
Shapes.Remove(target)
Shapes.Remove(targetMessage)
Controls.Remove(targetControl)
startAnimate = "" 'flag Off
EndIf
'Delay not needed here BUT takes some load of your CPU
Program.Delay(100)
EndWhile
'Handles button Clicks Only by setting a flag. The Main Loop will Process when buttonClicked = "True"
Sub OnButtonClicked
buttonClicked = "True"
EndSub