The Actions panel is a whole scripting environment in a box. It has three separate work areas: the Script pane, the Actions Toolbox, and the Script Navigator. To access the panel, choose Window > Actions or press Option-F9 (Mac) or F9 (Windows). The Script pane is a text window where you assemble scripts. You can enter actions into the pane manually (it acts like a text editor); you can also add actions from the Actions Toolbox or the Add pop-up menu. You can import scripts or pieces of script from an external file, such as one created with a stand-alone text editor. When you use behaviors, Flash adds the script directly to the Script pane of the Actions panel. When you activate Script Assist mode (it's on by default in Flash Basic 8), the area above the Script pane enlarges and becomes the Script Assist window, which displays information and input tools that help you create scripts. The Actions Toolbox contains most of the words (actions) that make up the ActionScript language. These pieces of code appear in hierarchical lists; click one of the folder-like icons to view the contents of a category. Double-click an action to add it to the Script pane. You can also drag items from the Actions Toolbox to the Script pane. (The list of ActionScript actions also appears in the Add menu. To access the menu, click the plus sign in the toolbar above the Script pane. Selecting an action from the Add menu adds it to the Script pane.) What Is Interactivity? By default, a published Flash file plays through its scenes and frames sequentially. The movie opens with scene 1, plays all those frames in order, moves to scene 2, plays those frames, and so on. Sometimes, that's appropriate; sometimes it's not. Imagine an online training course where you want the same five frames of general instructions to appear before each section of the course. You can make those frames a separate scene and then duplicate the scene so it appears repeatedly between other scenes containing the training sections. Duplicating scenes increases file size, however, slows the performance of your published course, and makes it more difficult to edit later. A more efficient method is to create one scene containing the instructions and direct Flash to repeat that scene when each training section ends. In addition, you may want the users taking your course to interact with the content: clicking buttons, dragging elements, or entering text to answer quiz questions, for example. And you may want the course to interact with the user, summarizing the quiz score. These are examples of interactivity in Flash. To achieve this type of interactivity, you must create a script that directs the playback of your published Flash content. You can do that with Flash's own scripting language, ActionScript (see "The Mystery of ActionScripting"). | The Script Navigator helps you to locate and maneuver through the scripts in your movie. This feature is especially useful when you've attached scripts to objects, because there is no special indication that an object has an attached script. Figure 13.1 shows the elements of the Actions panel. Figure 13.1. The Actions panel has three main areas: the Actions Toolbox, where you can choose actions; the Script Navigator, where Flash displays the elements in your movie that have scripts attached; and the Script pane, where Flash assembles the ActionScript. When Script Assist is active, information and scripting aids appear above the Script pane in an area called the Script Assist window. The Mystery of ActionScripting Flash Basic 8 and Flash Professional 8 both come with a full-fledged scripting languageActionScriptthat lets you add interactivity to Flash content. A script is a series of commands, or statements, that make Flash perform tasks at run timethat is, when a published Flash (.swf) file runs in Flash Player for viewing by your end users (see Chapter 16). You can create ActionScript scripts in various ways: Enter text in the Script pane of the Actions panel, create the text in an external text editor and copy the text into the Script pane, create the text in an ActionScript file (an external file separate from your Flash document) and have Flash pull the script in when you publish your movie. The Actions panel's Script Assist mode helps you enter code in the Script pane. For beginners, the word assist sounds attractive, and Script Assist can be helpful, but it isn't designed for someone who has no knowledge of scripting. With Script Assist, you create code by choosing radio buttons, check boxes, or menu offerings and entering text in special fields. Script Assist ensures that your ActionScript code has the correct syntax (see "The Mystery of ActionScript Syntax"). To use Script Assist, however, you must be familiar with the concept of scripting and with the specifics of ActionScript classes. If you know the kind of statements you need to create an interactivity, Script Assist will make sure you write them correctly; but Script Assist won't help you figure out what statements you need in the first place. Scripting novices and people who don't want to learn scripting can use the Behaviors panel. This panel lists a set of common actions you might want in your movie, makes it easy to enter information about how those actions should work in your movie, and then creates a script for you. The drawback to the Behaviors panel is that it creates scripts that don't follow the best practices of ActionScripting. The best scripts are continuous instructions that govern large chunks, if not all, of a Flash movie. Behaviors ask you to select an object on the Stage or a keyframe in the Timeline and attach instructions to that object or keyframe. When you use behaviors, you wind up with snippets of script throughout your Flash document; these can be difficult to locate and coordinate as you refine your Flash content. In addition the scripts for complex behaviors contain behind-the-scenes coding. You may find it difficult to recognize the correlation with your entries. Creating an ideal Flash script works something like creating a script for a play: A playwright creates a document containing all the dialogue for all the characters and all the stage instructions. Creating a script by using behaviors works more like putting together a skit, with individual actors developing dialogue and stage movements as they go. Anyone can go to the full script of a play to see what's happening when. To get the full picture of the skit, you have to interview each actor to find out who says what, where, and when, or watch the skit being performed. Although it would be a nightmare to develop a full-length, three-act drama using the skit model, plays and skits both have a place in the entertainment world. The scripting techniques in this book are inappropriate for developing an interactive online store or a complex e-learning course. But these simple techniques may be all you need to let your end users start, stop, and replay an animated cartoon; select a favorite scene to view; or link to a Web page. With any luck, they'll whet your appetite for learning more about ActionScript as well. |
|