Button States
Lets take a deeper look at how buttons work in flash. We will take a look at a buttons timeline and compare it to the main timeline, creating a roll state, down state and a hit state. Jump in let's see what that means.
Video Transcript
00:00So let's go back to our button, just see some of those interesting properties that a button has in Flash and has had since a very, very long time.
00:09If you double-click into the button, you'll be able to go into editing mode of the button.
00:13And you're going to see that it has a different timeline, and we haven't looked too deeply into timelines.
00:18But the regular timeline is based on time, which is basically from one through milliseconds through actually through frames.
00:25So when 24 frames pass, we could have created an animation or sequence of things that would happen between one through 24, because our frame rate is 24 frames per second.
00:38Now, if we double-click into our button again, we'll see that the timeline looks a little bit different.
00:43Instead of having time connected to it, their label is connected to it, there's an up, over, down, and hit.
00:50And the names are kind of indicative of what they do.
00:53So if I just, I'm going to click now F6 to create a new keyframe.
00:57And a keyframe enables me now to edit the content without changing the previous element.
01:03All right, so I want to change the color of this frame.
01:06So I'm just going to go right here.
01:08I'm going to change it to this color, right?
01:11So in our up state, it's going to be this weird color.
01:14And in the over state, it's going to be this bluish color, turquoise, I think it's called.
01:21All right, so if you run our application now, I just saved it and I'm running it.
01:25As soon as we roll over it, it will automatically change the color, which is kind of neat.
01:30Okay, so Flash automatically recognized that behavior and added it for me.
01:36And I can add another one, which would be the down state.
01:38Now, automatically, if I don't put anything, it says if I put an empty frame, which basically would be F5.
01:45And that basically means that it would inherit the same behavior as the last thing that was there.
01:50It extends the same behavior from frame one through frame down and hit.
01:55But I actually want our down to look different.
01:58Now, I can't go right here and change the color directly.
02:01If I do do that, I would then change the color of the over state as well because my key frame is the over state.
02:08So I'm just going to click on Command Z and undo that color change.
02:11And I'm going to, again, type F6 to enable me to create a key frame.
02:16Now, if F6 is not working for you, you might need to type function F6.
02:21And if nothing seems to work for you, you could always go to the Insert, Timeline, Keyframe.
02:28Okay.
02:29And another shortcut that you could use would be to right click or control click and search for Insert Keyframe.
02:36And all these ways are legit.
02:38There are some shortcuts that are just really nice to remember by heart, which is our F4 to get full screen,
02:43F5 to create a frame, F6 to create a key frame.
02:47Those are the F's that are really important and useful.
02:50And, of course, F1, which would take you to help, which is always good to have.
02:55All right.
02:56So we created a down state.
02:57Let's see what happens now.
02:58Now, with our down state, even when we click it, oh, we didn't change a color.
03:02We should change a color so we could actually see it.
03:04Let's change our color to black.
03:08And if we run it, we'll run more time.
03:11As we click and now my mouse is pressed, you can see that it turns black.
03:16All right.
03:17Now, the hit test is one last one, which is not – it's kind of intuitive.
03:22If we want to change the area that's hitable, such as, for example, we want the hitable area to be a rectangle and not a circle.
03:29Okay.
03:30So I could just – I could delete all of this.
03:32But I don't want to delete it because I want it to be easy for me to see my range.
03:37I want to just change that and just encapsulate that in a nice little rectangle.
03:42And as soon as I've done that, my hit state made it – my button clickable even when we're not on it,
03:49even when we're in the hot zone, which is now our new hit state.
