In frame 1 of a very simple flash file, I have the following code:
stop();
this.addEventListener(MouseEvent.CLICK, function(e) { gotoAndStop(5); });
gotoAndStop(10);
When I run the flash file, I expect that it would automatically step to frame 5 (ED. we think he means frame 10), but it does not. However, clicking anywhere does cause it to step to frame 5. The question is, why does gotoAndStop work from within the event handler, but not on its own on the main timeline?
Furthermore, if I put the exact same code on any other frame, gotoAndStop fires in that frame without having to be clicked. It appears gotoAndStop only fails to work on frame 1.
Edit / Answer: The answer to this one is really stupid, but I'll put it here in case anyone comes across it in the future. The resulting flash file was 500k, which was just big enough, even locally, to cause the gotoAndStop command to fire before the file was completely loaded. As a result, it couldn't possibly go to frame 5 or 10 because they didn't exist yet.
I knew I had to put in a preloader, but it was last on the list of things to do, and apparently, that came back to bite me in the ass. I added the gotoAndStop to an Event.COMPLETE handler and it works perfectly. Problem solved.