# Wait until frame is loaded?

**URL:** <https://forum.kirupa.com/t/wait-until-frame-is-loaded/304897>\
**Category:** flash\
**Created:** [February 16, 2010, 6:32am UTC](https://forum.kirupa.com/t/wait-until-frame-is-loaded/304897 "2010-02-16T06:32:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![RollingSton3](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@RollingSton3](https://forum.kirupa.com/u/RollingSton3)\
**Post date:** [February 16, 2010, 6:32am UTC](https://forum.kirupa.com/t/wait-until-frame-is-loaded/304897/1 "2010-02-16T06:32:41Z")

</div>

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

```auto

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:

```auto

 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!
