# gotoAndPlay gets stuck inside functions

**URL:** <https://forum.kirupa.com/t/gotoandplay-gets-stuck-inside-functions/165785>\
**Category:** flash\
**Created:** [October 13, 2005, 8:58pm UTC](https://forum.kirupa.com/t/gotoandplay-gets-stuck-inside-functions/165785 "2005-10-13T20:58:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![PiouPiou](https://avatars.discourse-cdn.com/v4/letter/p/a587f6/32.png) [@PiouPiou](https://forum.kirupa.com/u/PiouPiou)\
**Post date:** [October 13, 2005, 8:58pm UTC](https://forum.kirupa.com/t/gotoandplay-gets-stuck-inside-functions/165785/1 "2005-10-13T20:58:28Z")

</div>

Hi all,

I am going crazy!!! I cannpt figure out why whenever I put a gotoAndPlay action inside of a function it doesn’t PLAY, it just goes to the frame I tell it and then STOPS there, even though there is no stop action there, and if I use just a regular button to access it it plays fine. Here is an example of my code that isn’t working:

\_root.onEnterFrame = function() {   
startTime = getTimer();  
start\_txt.text = startTime;  
this.onEnterFrame = function() {  
currentTime = getTimer();  
current\_txt.text = currentTime;  
elapsedTime = (currentTime-startTime)/1000;  
if (elapsedTime \> 5){  
this.mc\_workspace.monitor\_transition.gotoAndPlay(2);  
loadMovie(“demo/sw\_workspace.swf”,this.mc\_workspace.monitor\_transition.mc\_container);  
}  
}  
}

it just goes to the monitor\_transition movie clip and stops on the second frame for no good reason! why why why why why!!!
