STEP 09 coding the BUTTON


Now that the movie clips are in place, we need to tell them what to do and when. For a basic rollover, the coding is fairly straightforward:

  • When the user 's pointer moves over the hit area, stop playing filmclip1 and begin playing daveclip1.

  • When the user's pointer moves off the hit area, stop playing daveclip1 and resume playing filmclip1.

I guess I've stressed the logic of this button enough at this point.

To add the necessary actions for controlling the rollovers, follow these steps:

  1. Lock all layers except the button layer by pressing Alt / Option while clicking on the button layer lock control as shown in figure 04:21.


    Figure 04:21.

    graphics/04fig21.jpg


  2. Select the keyframe in the button layer and choose Modify > Instance again.

  3. In the Instance Properties dialog, select the Actions tab.

  4. Select the Add Action button (the plus sign) and choose On MouseEvent.

    The initial code is written into the list window and the On MouseEvent options appear to the right in the Parameters pane.

  5. Select the Roll Over checkbox from the On MouseEvent options and uncheck the Release checkbox (see figure 04:22).


    Figure 04:22.

    graphics/04fig22.jpg


    Remember, on rollover, the first thing you want to happen is to stop filmclip1 from playing. To do this, you must first specify that clip as the one you want to control via the Tell Target action.

  6. Click the Add Action button and select Tell Target. When you do this, the names of the available targets, the two movie clips, appear in the Parameters pane.

  7. Double-click the filmclip1 target.

    The filmclip1 label is added to the Tell Target code as shown in figure 04:23.


    Figure 04:23.

    graphics/04fig23.jpg


    After you've found the proper target, it's time to specify the action(s).

  8. From the Add Action button, choose Go To.

    The initial action is to stop filmclip1 from looping.

  9. In the Go To Parameter pane, select the Label option and type in filmstop (see figure 04:24).


    Figure 04:24.

    graphics/04fig24.jpg


    The second part of the onMouseOver event is to start the second movie clip playing. You insert actions identical to those just created; however, the actions have different parameters.

  10. Select the script line End Tell Target.

    You can't put one Tell Target inside another, so you have to be sure to add a second Tell Target directly after the first.

  11. Repeat steps 610, changing the parameters like this:

    • For Tell Target, choose daveclip1.

    • Rather than the Go To action, select the Play action.

The resulting code should look like that shown in figure 04:25.


Figure 04:25.

graphics/04fig25.jpg




Flash Web Design The Art Of Motion Graphics
Flash Web Design oder: the art of motion graphics
ISBN: 3827256623
EAN: 2147483647
Year: 2005
Pages: 192

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