Adding a Simple Tween


We should now add something to our movie that will give us some action. I'm tempted to give you a couple lines of ActionScript to make an instance move about the stage, but that topic is probably best left to the next chapter, which is getting close now anyway. Instead, we're going to do something that we'll probably never do again: tween. Tweening, as you might have read in the tutorials, is a tool that creates motion in Flash. Specifically, a designer places a movie clip on the stage in a particular frame on the timeline. The designer tells Flash to tween the movie clip. Finally, the author changes the position, orientation, size , shape, and so on, of the movie clip at some frame further down the timeline. When the final movie plays, Flash fills in the frames in between, and changes to the clip become fluid over time. An example will help explain this concept.

Click on and delete any instances on the stage. Now create a new instance of veggie by dragging it onto the stage from the library. (If you don't have veggie in your library, go back and reread the section on importing graphics and sound.) Click on the veggie instance on the stage. Now go up to the timeline and notice that the layer that contains veggie is highlighted. I know this is true because when you select a clip on the stage, the layer it exists in is automatically selected in the timeline. Use the Insert pull-down menu and select Create Motion Tween. Now right-click on Frame 20 in the highlighted layer and choose Insert Frame from the pop-up menu. Don't insert a keyframe ”just a normal frame. This action causes Flash to add an empty frame to the twentieth frame in the timeline and to fill all frames in between with empty frames. Finally, with the twentieth frame highlighted (it should be selected if you haven't done any other clicking around on the timeline), drag the veggie instance somewhere else on the stage, as far away from its current location as possible. This completes the tween. Veggie now moves across the stage when the movie is played or previewed.




Macromedia Flash MX 2004 Game Programming
Macromedia Flash MX 2004 Game Programming (Premier Press Game Development)
ISBN: 1592000363
EAN: 2147483647
Year: 2004
Pages: 161

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net