STEP 17 adding object-oriented actions to the NAVIGATION BUTTONS

STEP 17 adding object-oriented actions to the NAVIGATION BUTTONS

Now that the generic scripts are built, it is time to add the actions to the various buttons that will call these routines. Each of the three buttons is set up as a symbol and then different actions are added to the instances of those symbols present on the stage. The actions use On mouse eventssuch as On (Roll Over) and On (Roll Out)to set variables and trigger the generic action built in the previous section.

about manifestival button

All three of the primary navigation buttons are a similar combination of setting variables and calling scripts. Let's re-create how the About ManiFestival button was set up, with the following steps:

  1. To create the button, double-click the instance of your button symbol to open the Instance Properties dialog.

  2. On the Actions panel, choose On MouseEvent from the Add Actions button.

  3. Choose the Roll Over event option on the right, as shown in figure 08:30.

    Figure 08:30.


  4. Set three variables, by choosing Set Variable from the Actions list, as follows :

    Variable Value
    /scripts:line_x 544
    /scripts:line_y 180
    /scripts:dancer_framelabel spin

    In each case, you're setting a variable for the /scripts object and then giving it a specific value. With the variables set, you're ready to invoke the routine.

  5. With the last Set Variable line selected in the script, choose Call from the Add Actions list and in the Frame field (see figure 08:31) enter /scripts: RolloverScript.

    Figure 08:31.


The rollover portion of the action is now donelet's move on to the rollout section.

  1. Select the End On action and choose On MouseEvent again from the Add Action list, this time choosing the Roll Out option.

  2. Set two variables this time, as detailed here:

    Variable Value
    /scripts:whichmovie / subway
    /scripts:logo_x 12

    With these variables, you're setting it up so that the /subway movie plays when the user 's mouse rolls off this button and the X Position of the logo object is 12 pixels in.

  3. Select the last Set Variable line and then choose Call from the Add Actions list, entering /scripts:RolloutScript in the Frame field.

    Here's the completed action for the About the ManiFestival button (see figure 08:32):

    Figure 08:32.


  On (Roll Over)   Set Variable:   "/scripts:line_x" = "544"   Set Variable:   "/scripts:line_y" = "180"   Set Variable: "/scripts:dancer_framelabel" =   "spin"   Call ("/scripts:RolloverScript")   End On   On (Roll Out)   Set Variable: "/scripts:whichmovie" = "/subway"   Set Variable: "/scripts:logo_x" = "12"   Call ("/scripts:RollOutScript")   End On  

Setting up the other buttons is a similar process. For comparison's sake, here are the two additional scripts:

First, here's the completed action for the About Films button (see figure 08:33):

Figure 08:33.


  On (Roll Over)   Set Variable: /scripts:line_x = 650   Set Variable: /scripts:line_y = 144   Set Variable: /scripts:dancer_framelabel = one   Set Variable: /scripts:logo_x = 12   Call (/scripts:RolloverScript)   End On   On (Roll Out)   Set Variable: /scripts:whichmovie = /tunnel   Set Variable: /scripts:logo_x = 12   Call (/scripts:RollOutScript)   End On  

And here's the completed action for the Featured Animation button (see figure 08:34):

Figure 08:34.


  On (Roll Over)   Set Variable: /scripts:line_x = 777   Set Variable: /scripts:line_y = 200   Set Variable: /scripts:dancer_framelabel = two   Call (/scripts:RolloverScript)   End On   On (Roll Out)   Set Variable: /scripts:whichmovie = nothing   Set Variable: /scripts:logo_x = 12   Call (/scripts:RollOutScript)   End On  

You should recognize most of the variables from the previous section. The only value that may come as a surprise is the one found in the On (Roll Out) section of the Featured Animation movie: "nothing." If you recall, the variable whichmovie is used to determine which movie (I'm nothing if not literal) is played in the generic RolloutScript. Here, "nothing" is not a movie but a simple rectangle graphic. Since you cannot "play" a graphic as you can a movie clip in Flash, no action takes place when whichmovie is set to "nothing."

I've gotten into a lot of detail here for this particular movie. Of the details covered, the following list contains a few major areas:

  • Using the load movie command to load external movies into Target Objects

  • The Script objectkeeping all of your scripts in once place

  • Setting variables

  • Using the call action

  • Setting variables and using the call command to simulate passing parameters

  • Using the If End action

  • Using the If End Else action

  • Setting properties

I hope this gives you some insight into Flash 4's ActionScript. I've found it to be simple, elegant, and extremely powerful compared to other scripting languages. Flash 4 gives us all the power to create 2D arcade-like games , interactive multiuser applications, and even entire web sites with only one page of HTML. I hope you can use some of your newly gained knowledge to create your own interactive applications.

And now, back to Hillman

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 © 2008-2017.
If you may any questions please contact us: