Flash: Stop motion blocks gotoAndPlay

Click For Summary
SUMMARY

The discussion identifies a bug in Adobe Flash, specifically in versions CS3 and MX, related to the gotoAndPlay function when using large images in stop motion animations. The issue arises because the playhead does not immediately jump to the specified frame if the images have not fully loaded. A solution is provided, which involves adding a stop action in the first frame and moving the switch statement into an onEnterFrame event to ensure the images are loaded before executing the gotoAndPlay command.

PREREQUISITES
  • Understanding of Adobe Flash CS3 or MX
  • Familiarity with ActionScript 2.0
  • Knowledge of frame-based animation techniques
  • Basic concepts of loading assets in Flash
NEXT STEPS
  • Implement the provided solution using ActionScript 2.0 in Flash
  • Explore the differences between using images and vector graphics in Flash animations
  • Learn about the onEnterFrame event in ActionScript
  • Investigate best practices for optimizing asset loading in Flash projects
USEFUL FOR

This discussion is beneficial for Flash developers, animators working with stop motion techniques, and anyone troubleshooting ActionScript-related issues in Adobe Flash.

mtanti
Messages
172
Reaction score
0
I think I found a bug in Flash. It spans from CS3 to MX and perhaps earlier.

I did a stop motion animation of me turning the pages of a scrap book (frames of a video recording). Then I put labels on each frame where a page is completely turned and did some actionscript (gotoAndPlay) so that I can choose from which page to start and to which page to arrive.

The problem is that gotoAndPlay does not actually go to the required frame. Instead it goes through all frames and only after that will the play head go to that frame. This only happens when images are used, when flash drawings are used, it will works just fine. And the weird thing is that when only the first half of the key frames between labeled frames are used, it works just fine.

Here's the fla file (flash 08): http://rapidshare.com/files/141420616/scrapbook.fla.html

Here's how it works:
Layer 'code' contains actionscript and labels, layer 'animation' contains the stop motion pictures.
First frame of layer 'code' contains 2 variable initializations. currState holds the current page of the scrapbook and nextState holds the destination page (both zero based). There are 3 pages in all. A switch statement makes a gotoAndPlay to the required frame depending on currState (this is the part which doesn't work).
After the play head is on the frame with the start page, each labeled frame will contain actionscript to check if nextState matches the page on that frame and execute stop() if so.

I hope this is enough information to help you. If you need anything else just ask.
 
Last edited by a moderator:
Technology news on Phys.org
This behavior is not exactly a bug, it happens because when the code in your first frame gets executed the remaining frames (which contain large images) haven't yet loaded. What ends up happening is that, your gotoAndPlay call will fail (flash hasn't yet loaded the named frame) and movie will continue to play. The movie continues to play because that's the default behavior - when the movie starts it will play unless you have a stop() action in the first frame - and also because gotoAndPlay calls play().

You can fix this first by putting a stop action in your first frame and then moving your switch statement into the onEnterFrame event which gets executed a few times a second. Inside that event you'd check to see if the movie has finished loading and only then let control go to the switch statement. Try putting the following code in the first frame:
Code:
stop();
currState = 2;
nextState = 2;
_root.onEnterFrame = function(){
	if(_root.getBytesLoaded() >= _root.getBytesTotal()){
		switch (_root.currState) {
			case 0: gotoAndPlay("closed"); break;
			case 1: gotoAndPlay("page1"); break;
			case 2: gotoAndPlay("page2"); break;
			case 3: gotoAndPlay("page3"); break;
			default:
				throw "error";
		}
		_root.onEnterFrame = null;
	}
}
 
!
It works! Now why would that happen if I'm not using simulate download?

Thanks sooooo much! I've posted this on 4 foraa and this is the only one I got an answer from... PF rulez!
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
Replies
2
Views
4K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 184 ·
7
Replies
184
Views
24K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K