Friday, February 8, 2008

Movie Clips and Timelines in Flash

One of the most difficult concepts for me to grasp when I started learning how to use Flash was the idea of using multiple timelines. It made sense to me to have the main timeline but I just couldn’t wrap my brain around what the advantage of more timelines would be. Why not just animate everything on the one timeline to make it less confusing, I figured. Then one day the light bulb came on in my head and all at once I realized all the advantages this concept offered.

The idea is that you have a base timeline referred to as the main or _root timeline. This is the main timeline in a flash file. In the frames of this timeline you can place a variety of objects including shapes, text, video, music, pictures, buttons and movie clips. Movie Clips are special because they are basically another Flash movie complete with its own independent timeline and objects. The difference is that you can then animate the position, scale, transparency and other attributes of the entire movie clip from the _root timeline allowing you to easily create some very complex animations.

Think about it like the windshield wipers on a car. In essence they are part of the car and if the car moves a few feet forward in a parking lot, the wipers will move along with it. Now if these wipers are turned on they would not only be moving forward with the rest of the car but they would also be move up and down relative to where the car is in the lot. In this metaphor of the parking lot is your _root timeline and the car as a movie clip. The windshield wipers don’t exist directly on the _root timeline but rather are an object inside the car movie clip. This way we can animate the car on the main timeline without having to worry about whether the wipers are moving or not. Of course you could animate every moving part of the car on the _root timeline but if you did that you would have to be very careful that the car didn’t start moving ahead of the wipers as that wouldn’t look realistic at all. And then if you needed to change the animation it would be a ton of work updating the cars position as well as the wipers. Fortunately using the movie clip method we can stop the care and keep the wipers moving or move both at the same time very easily and the car will always take the wipers with it.

This whole concept is really very similar to how real live objects work so once you get use to it, the whole thing is quite natural. Think about it: I can move my fingers but their position changes will also change when I move my hand. My hand will move relative to my arm, my arm to my body and so on. My body, even if it’s sitting still, is still moving in our solar system relative to Earth’s movement…gets pretty complicated. But everything is connected and is a “child” of something else and that’s the way Flash works as well. Movie clips with their timelines just make up one huge family tree.

No comments: