Wait until frame is loaded?

I have a textarea named “debug” on frame 2 that does not exist on frame 1
Using this code:


function outputHello(){
  debug.text="Hello";
}
stop();
gotoAndStop(2);
outputHello();

It sometimes (not all the time) fails out with error #1009 because debug hasn’t been drawn yet before trying to access it.

If instead I use this code:


 function outputHello(){
   debug.text="Hello";
 }
 stop();
 gotoAndStop(2);
 setInterval(outputHello,3000);
 

It always works. However I hate having to make an arbitrary guess as to how long frame #2 is going to take to draw after I call gotoAndStop(2);

Is there a way to check that frame #2 has completed or an event I can listen for so that as soon as frame #2 is complete, I can then execute a function (such as outputHello() in my test)?

Thanks for any help!