Flash Web Design oder: the art of motion graphics
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:
The rollover portion of the action is now donelet's move on to the rollout section.
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:
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 |