Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
For your first code snippet, choose something very simple. I'm going to demonstrate the use of one of the simplest code snippets that simply adds a stop command into the Timeline to stop any existing animations. For this demonstration, I'll use a preexisting file that's available from the Exercise Files folder. If you have access to the Exercise Files, go to the Exercise Files folder, and then to the subfolder Ch01_SimpleSnippets. Then open the file SimpleSnippet.fla.
This presentation has multiple layers. Most of the layers have static, graphical, or movie clip object. This layer named bike has a motion tween. The motion tween causes a movie clip symbol to travel across the screen from right to left. The movie clip symbol itself has a frame-by-frame animation in its Timeline. I'll test the movie by pressing Ctrl+ Enter on Windows or Command+Enter on Mac. You'll see that the biker crosses the screen over and over again, traveling from right to left.
Now I want to add a stop command in the first frame of the movie. This is a simple snippet. It will execute when the playhead gets to the frame that contains the code. So before adding the snippet, I'll place the playhead in frame number 1 of the Timeline. Notice that its position by default. Then I'll go to the menu and choose Window > Code Snippets. I'll go to Timeline Navigation, and then I'll double-click Stop at this Frame. That causes two results.
Notice in the Timeline that a new Actions layer has been added. And you can tell in the first frame by the little scripted a that ActionScript code has been added to that first frame. Now I'm going to expand the size of the Actions panel so we can see all of the code and comments that have been added. You'll see a block comment that describes what the code does, and then the simplest of commands, the stop command. That means that when this command is encountered that the playhead should stop moving on the Timeline.
I'll close the Actions panel and once again test the movie. You'll see that the biker is no longer traveling from right to left, but the legs are continuously moving, and the hairs moving with the wind. That's because of the frame-by-frame animations in the movie clip symbol itself. So I'll close the test movie. Then I'll go to the Library and locate the movie clip symbol, mcBiker. I'll double-click to open that movie clip. Here is the frame-by-frame animation.
Notice all the different frames that are involved in the animation. I'll close the Code Snippets panel. Then I'll scrub through the Timeline within the movie clip symbol, and show you the animation. Notice the legs moving. Now I'll show you that you can also add the code snippet within a movie clip symbol's timeline. Once again, I'll place the playhead in frame number 1, go back to the Code Snippets panel, to Timeline Navigation, and double-click Stop at this Frame. That adds the Stop command into frame number 1 of the Actions layer.
I'll return to Scene 1. I'll test the movie again, and here is the result. The legs are no longer moving. But with the wind still blowing, the hair is blowing in the wind. So the thing to learn from this demonstration is that you can add code snippets into Timeline, either the movie's main timeline or into timelines of any movie clip symbol.
Get unlimited access to all courses for just $25/month.Become a member
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.