Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
A great way to add interactivity to your Flash applications is to use something called Frame Labels. In this movie we'll talk about what Frame Labels are and how to create them. If you're following along, I'm working in O2_Understanding_Labels.fla in the Chapter 06 folder in the Exercise Files folder. On the stage, let's double-click the robot to enter its timeline. Currently clicking the dance 1, 2 or 3 buttons navigate to frame 1, 2 or 3 of the robot movie clip.
Now if I were to move these frames around, so let's say I selected frame 3 and I moved it to frame 15, and I selected frame 2, then I moved it to frame 10, if I tested the movie, then the buttons wouldn't work properly. I can show how that works right now. Command+Return on the Mac or Ctrl+Enter on the PC to test the movie. When I click the buttons, it seems that the buttons aren't working. But what's happening is Flash is navigating to frame 1 for dance 1, frame 2 for dance 2, and frame 3 for dance 3.
Using Frame Labels, you can associate a frame with a name, and that way your code's a little bit more dynamic and it's a little more flexible. So let's talk about how to do that. Select the robot layer and click the Insert Layer button to insert a new layer, and change the name of the new layer to labels. Now that's the first step in creating a frame label is to create a layer to hold your labels. Now in the labels layer I'm going to select the first keyframe, and I'm going to give this frame a label of dance1. It's to tell the Flash that this is the dance 1 frame.
To give a frame a label, the frame first needs to be a keyframe. So this label's a keyframe and then in the Property inspector find the Frame Label field - it's at the left side of the Property inspector. Click in the Frame Label field and type dance1, no spaces, all lowercase, and you can press Enter or Return to accept the change and notice at the top of the screen in the labels layer that you see dance1. There's also a little flag that shows that there's a Frame Label on that keyframe.
Let's create another Frame Label. Select frame 10 of the labels layer and press F7 on your keyboard to insert a blank keyframe. With that frame selected, in the Property inspector click in the Frame Label field and type dance2. Now click frame 15 in the labels layer and press F7 on your keyboard to create a blank keyframe, and then in the Frame Label field in the Property inspector type dance3. Notice that we don't see the text for dance3 like we see it for dance1 and dance2. So what I'm going to do is add some more frames to the timeline so I can see the Frame Label for dance3. I'm going to deselect everything by clicking on the stage away from the robot, and I'm going to click and drag from frame 20 of the labels layer down to frame 20 of the robot layer.
I'll press F5 on my keyboard to extend the timeline and now we can see dance3. And that's a look at how to create Frame Labels. Now that you know how to create Frame Labels, you can navigate to them using your buttons. We'll talk about how to do that in the next movie.
Get unlimited access to all courses for just $25/month.Become a member