Measuring time between two events

so i applied you code and am very grateful for you help! Sorry i have one more question... i know it might be super basic but,

how do i declare timingFlag, timingMillis, and timeOff so it corresponds and reacts with my code?

Seriously thank you so much for all your help!