# Going to a frame and accessing a variable, at one shot

**URL:** <https://forum.kirupa.com/t/going-to-a-frame-and-accessing-a-variable-at-one-shot/309215>\
**Category:** flash\
**Created:** [May 10, 2010, 8:43am UTC](https://forum.kirupa.com/t/going-to-a-frame-and-accessing-a-variable-at-one-shot/309215 "2010-05-10T08:43:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ayman](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Ayman](https://forum.kirupa.com/u/Ayman)\
**Post date:** [May 10, 2010, 8:43am UTC](https://forum.kirupa.com/t/going-to-a-frame-and-accessing-a-variable-at-one-shot/309215/1 "2010-05-10T08:43:09Z")

</div>

Hi guys,

I am sure this is a bug with flash, and looking for a smart workaround.

Now I have a 20 frame movieclip (named mc), and by default the playhead is stopped at frame 0 of that movieclip. At frame 10 I have a movieclip instance there named “apple”. Now I want to tell mc to go to frame 10, and immediately access “apple” movieclip. This is what I do (from the main timeline):

mc.gotoAndStop(10);  
trace(mc.apple);

it prints out null (appled is undefined). However, when I put a timer (say of 5 milliseconds) before calling the trace statement, then it works and can access apple.

I dont want to rely on timers, since the timer duration depends on different circumstances. At the same time, I do not want to put code anywhere except the first frame of the main timeline. How can such a thing be solved? Just to make it more difficult (since I know the kind of solution some will be suggesting), at frame 0 of mc, we also have a different movieclip named apple as well! 🙂

Thanks guys
