Refresh/reniew

hey all quick question I have a project where based on a time/ am or pm a message appears ‘good morning, good afternoon, etc’ the problem that I have how do I keep this constantly refreshed? right now when I start application let’s just say a ‘Good Morning’ message appears if I don’t close my application for all day this message will not change unless I close it and re-open it. What I need is to add a code that keeps updating or something. Also this is not a webpage project so refresh my page won’t work, I am implimenting this into an application/software.

this is what I have:

var myDate = new Date();
var hour = myDate.getHours();
if (hour < 12) {
   this.gotoAndStop(2); // morning
}
else if (hour < 12+6) {
   this.gotoAndStop(3); // afternoon
}
else {
   this.gotoAndStop(4); // evening
}