Using invisible buttons to make the lure turn

 < Day Day Up > 



In this section, you make buttons on the main timeline, which also contains the actions to trigger the movement of the fishing lure on the Stage. Because you do not want a visual representation of these buttons in the main movie, make them invisible. Invisible buttons contain a only hit state, or a click- able area. The up, over, and down states of the buttons don't exist. To finish this project, follow these steps:

  1. In the main movie, click the top layer, and click the plus sign to add a new layer. Name it buttons. You are going to be making invisible buttons to move the lure.

  2. Select the Rectangle tool. In the Toolbox, click the stroke color box, and then click the No Color icon (red slash). Use any color fill.

  3. Drag a rectangle on the Stage. In the Info panel,make the width 30 and the height 280.

  4. With the rectangle still selected, choose Insert ® Convert to Symbol. Choose the Button behavior and name it invisible. Double–click the button to enter Symbol Editing mode.

  5. The rectangle you drew is in the up state of the button. To make the button invisible, it needs to be in the hit state. Place your mouse over the up state in the timeline, and wait for the hand icon to appear. Click and drag to the hit state. If you prefer, you can cut and paste from the up state to the hit state.

  6. Select Scene 1 to return to the main movie. You'll notice the rectangle has turned to light blue. This is the same way a hotspot looks in Fireworks and Dreamweaver. It's a visual representation and won't appear this way in your movie.

  7. Position the rectangle to the left of the lure and to the left as shown in the following figure. The coordinates in this file are x: 95 and y: 62.


    The first invisible button in place

  8. You are going to add the actions to this invisible button. Open the Actions panel, and open the Actions category, the Movie Control category, and double–click goto. In Normal mode, you'll see two radio buttons that say Go to and Play and Go to and Stop. Select Go to and Stop. The following figure shows the code in the right pane. Next, change some of the parameters.

    click to expand
    The Actions panel with gotoAndStop added to the invisible button

  9. Select the on (release) line of code. The Parameters window changes. Uncheck Release, and select Roll Over and Drag Over to allow the actions between the curly brackets to occur when the mouse rolls over this invisible button on the Stage.

  10. In the Parameters area, be sure the type is set to Frame and the number is 1.

Now you need to tell the button where the frame you want to go to is located. To do this, add the path. Root is the name of the main timeline. To talk to the lure Movie Clip that exists on the main timeline, specify _root.lure. Lure is the instance name of the fishing lure Movie Clip that is on the Stage. Instance names help Flash understand which Movie Clip you want to perform actions on.

  1. Switch to Expert mode. Place your cursor in front of gotoAndStop. Type _root.lure. The final code should look like this:

    on (rollOver, dragOver) { _root.lure.gotoAndStop(1); }
  2. Duplicate the invisible button by pressing the Alt (Option) key/ Drag a new copy. Make eight more copies. Line the buttons up against the first one.

  3. Select invisible button 2. The copy has the same ActionScript already added to it because you have duplicated button 1. All you need to do is change the frame number from 1 to 2 (in Expert mode). Repeat this process for numbers 3-8. In the invisible button 9, leave it as is with Frame 1. You want the first and last buttons to target the first frame for a smoother motion.

Now test your movie. Pass your cursor back and forth over the lure, and it will turn.



 < Day Day Up > 



Macromedia Studio MX Bible
Macromedia Studio MX Bible
ISBN: 0764525239
EAN: 2147483647
Year: 2003
Pages: 491

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net