Showing posts with label Movie Clips. Show all posts
Showing posts with label Movie Clips. Show all posts

Friday, February 29, 2008

Flash Quick Tip - Seamless Looping Tween

Have you ever wanted to make an object rotate continuously in Flash? It sounds simple enough:

1) Convert your object to a Symbol such as a Movie Clip
2) Create a second keyframe a ways out from your first one
3) Tween the two key frames
4) Set the rotation in the Frame Properties of the first keyframe to either Clockwise or Counterclockwise.


This does work and as long as the second keyframe is the last frame in the timeline, the animation will loop continuously when you play or preview your Flash movie. Of course there's one small problem: The animation pauses briefly every time it loops back to the beginning. This is because the first and last frames (the keyframes) are the exact same thing while the rest of the frames all show the object in a slightly different position.

To remedy this, all you have to do is add a couple extra step to the list above. After you've set the rotation (or any other property):

5) Right-Click on the frame just before the last keyframe and select "Insert Keyframe"
6) Right-Click the last keyframe and select "Clear Keyframe"

Now when you play or preview your Flash movie it will loop seamlessly. The one thing you need to keep in mind is that if you need to change the length of the tween (the amount of frames in between the keyframes) you will need to redo all the steps otherwise you'll again see a slight stutter.

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.