FLASH Buttons - Part III


© Umais Ahmad
Articles in this Topic    Discussions in this Topic

This is our last article on Buttons. Last time we created a button, today we learn to link it to a frame and URL.

Linking button to frame

Right-click on the button and choose Actions. These actions are surely new to you. What are Actions? Actions are very similar to JavaScripts that are responsible for performing variety of tasks in a movie. These are the actions that allow Flash to behave as a programming language, e.g. you can use Flash in creating unimaginable interactive games. Excellent repute of the Flash 5 version is due to its vast actions, which are not found in previous versions.

An Object Actions window will open. Click Plus sign (+) and choose Go To from the Basic Actions. Click gotoAndPlay(1); and type 5 in the Frame below. After that the actions should look like here below.

on (release) {
gotoAndPlay(5);
}

Lets understand these action scripts.

on (release)

It defines on which mouse event, statement(s) in the braces {} will execute. Its default value is release. You can change it by clicking above script and choosing Event below.

{
gotoAndPlay(5);
}

It defines statement(s) in the braces that will execute on button release. Here only one statement is used however you can use more than one statement as well. This statement orders the PlayHead to go to frame number 5 and starts playing. Click gotoAndPlay(5); statement and unselect the Go to and Play check box in the bottom. After this the statement will change to gotoAndStop(5);. This statement orders the PlayHead to go to frame number 5 and stops here. Remember semicolon at the end of statement is a mark of completion of one statement.

We have set the frame number value to 5 but this frame doesn't exist in our movie. So click frame number 5 and choose Insert > Blank Keyframe. Be sure frame 5 is selected and type 'This is Frame 5' by using Text tool. Click Control > Test Movie, oops! Movie is constantly playing between 1 (button) and 5th (text) frame that doesn't allow the user to press button. It means we have to stop it at frame number 1 (button). So right-click on frame number 1 and choose Actions. Click Plus sign and choose Stop from the Basic Actions. Again test your movie by pressing Ctrl+Enter keys combination. Wa!

As you see by using gotoAndStop(5); script, movie stops at frame number 5. What will happen if we use gotoAndPlay(5); script? The movie will immediately come to frame number 1 after displaying frame number 5.

Go To Page: 1 2


Post this Article to facebook Add this Article to del.icio.us! Digg this Article furl this Article Add this Article to Reddit Add this Article to Technorati Add this Article to Newsvine Add this Article to Windows Live Add this Article to Yahoo Add this Article to StumbleUpon Add this Article to BlinkLists Add this Article to Spurl Add this Article to Google Add this Article to Ask Add this Article to Squidoo