Chapter 17. Making Your First Flash CS5 Project

IN THIS CHAPTER

  • Creating a Main Timeline layout

  • Adding navigation elements to a presentation

  • Using the TextArea component

  • Creating an effect with a custom BlurFader component

  • Adding accessibility information to movie elements

Now that you've learned the basic principles behind Flash actions, you probably want to start creating a presentation to put on a Web site. This chapter integrates several basic production principles and teaches you how to make a simple interactive Flash movie that has basic navigation and text functionality.

Note

In this edition of the Flash Bible, we've updated all examples with interactivity to use ActionScript 3.0, which is compatible with Flash Player 9 or later. If you need to create projects with legacy versions of ActionScript (1.0 or 2.0), refer to previous editions of the Flash Bible (Wiley).

The Main Timeline As the Site Layout

Before you can start creating a Flash project, you need to know what you're communicating — what is the basic concept of the experience? Is this an all-Flash Web site? Is this a Flash animation that introduces some other type of HTML-based content? For the purposes of this chapter, you create a Flash movie for a basic all-Flash presentation. In a sense, this project is the Flash equivalent of a Microsoft PowerPoint presentation. Let's look at the completed project (shown in Figure 17.1) that you will create in this chapter.

Note

In a Web browser, open the main.html document, located in the ch17/deploy folder of this book's CD-ROM. This movie contains two completed sections of the presentation.

The completed presentation

Figure 17.1. The completed presentation

When you load the main.html file into a browser with the Flash Player 10 installed, you see the presentation's title, "Digital Video Production," along with four navigation buttons that take you to each section of the presentation. The opening section, Introduction, has scrolling text featuring the TextArea UI component. When you click the Video Equipment button in the navigation bar, a Movie Clip featuring five video items appears along with another instance of the TextArea component. The Next and Previous buttons enable you to browse the video items. Each video item uses a custom component that blurs and fades the item onto the stage.

If you have a screen reader installed and are using the Windows operating system, you will hear the screen reader describe each item in the Introduction section. A screen reader is an application that assists visually impaired computer users by speaking text aloud. The Flash Player 9 ActiveX control works only with screen readers that adhere to the MSAA (Microsoft Active Accessibility) specification built into Windows operating systems. As of this writing, only a handful of screen readers, such as the Window-Eyes screen reader by GW Micro and JAWS from Freedom Scientific, adhere to MSAA. In this chapter, you learn how to add accessibility information to elements in your Flash document.

Creating a plan

When you know what goals you want to achieve with your Flash content, you should map the ideas on paper (or with your preferred project planning or flowchart software). I create a basic presentation for digital video production that has four areas: introduction, video equipment, audio equipment, and editing software. The organizational chart for this site has four discrete areas, as shown in Figure 17.2.

Our organizational chart helps us plan our Flash movie architecture.

Figure 17.2. Our organizational chart helps us plan our Flash movie architecture.

In this chapter, you create the first two sections: introduction and video equipment. If you prefer, you can continue to develop the presentation with graphics provided on the CD-ROM.

Setting up a local folder structure

As described in Chapter 3, an ideal production environment separates your authortime files, such as Flash documents (.fla), from your runtime files, such as Flash movies (.swf) and Web pages (.html). Before you begin creating content in Flash CS5, follow these steps to create suitable folders for your project's content:

  1. Pick a location on your local hard drive to store the files for this chapter. Create a folder named ch17 in this location.

  2. Inside of the ch17folder, create two folders: deployand src. The deploy folder will contain the runtime files, and the src folder will hold the authortime files.

  3. Inside of the srcfolder, create a folder named actionscript. Inside of the actionscript folder, create a folder named includes. The includes folder will store ActionScript files (.as) that contain code referenced from the Flash documents (.fla) stored in the src folder.

Now you have the necessary folder structure to begin building the project in this chapter.

Determining Flash movie properties

After you've made your organizational chart, you'll want to determine the frame rate, size, and color of the Flash document. I've skipped much of the "real-life" planning involved with Flash-based Web sites, which are discussed in Chapter 3. For this example, I have made a starter Flash document for you to use that contains all the elements necessary to complete the chapter. This document contains some of the basic graphic elements already positioned on the Stage.

Note

Make a copy of the main_starter.fla document, located in the ch17/src folder of this book's CD-ROM.

Open the starter document in Flash CS5. This document uses a frame size of 640 × 480 (to maintain the aspect ratio of most computer monitors), a standard frame rate of 24 fps (frames per second), and a white background color. These are set in the Document Properties dialog box, shown in Figure 17.3, which is accessed by choosing Modify

Determining Flash movie properties
The Flash document properties

Figure 17.3. The Flash document properties

Mapping presentation areas to keyframes

When the Flash document properties have been determined, you can create a Main Timeline structure for the presentation. Because there are four areas in the project (introduction, video equipment, audio equipment, and editing software), you'll have keyframes on the timeline that indicate those sections.

  1. Create a new layer and name it labels. Place this layer at the top of the layer stack in the Timeline window.

  2. With the Selection tool, select frame 10 of the labels layer, and press the F7 key. This creates a keyframe on frame 10.

  3. With the keyframe selected, open the Properties panel. In the Name field of the Label section, type intro. After you have typed the text, press Tab (or Enter) to make the name "stick."

  4. Repeat Steps 2 and 3 with frames 20, 30, and 40, with the frame labels video, audio, and software, respectively.

  5. Select frame 50 of the labels layer, and press F5. This enables you to read the very last label, software. Your Timeline window should resemble Figure 17.4.

    You use frame labels to differentiate each section of the site.

    Figure 17.4. You use frame labels to differentiate each section of the site.

  6. Select frame 50 on all other layers in the Timeline window, and press F5 to extend the content on these layers across the entire timeline, as shown in Figure 17.5.

    The content in the heading, background, and frame layers will be present throughout the entire movie.

    Figure 17.5. The content in the heading, background, and frame layers will be present throughout the entire movie.

  7. Save your Flash document as main_100.fla in the src folder you created earlier in this chapter.

  8. Make a new layer, and rename it actions. Place this layer below the labels layer. Add a keyframe on frame 10 of the actions layer, and open the Actions panel (F9/Option+F9). Type the following code into the Script pane:

    stop();
  9. Close the Actions panel, and open the Properties panel. Make sure that frame 10 of the actions layer is selected. In the <Frame Label> field, type //stop. The // characters assign a frame comment rather than a frame label. Although this step isn't necessary for the functionality of the movie, frame comments can provide quick and easy access to the designer's or programmer's notes. Your Timeline window should now look like Figure 17.6.

    Unlike labels, you cannot use frame comments in ActionScript. Comments can provide quick visual references for ActionScript code.

    Figure 17.6. Unlike labels, you cannot use frame comments in ActionScript. Comments can provide quick visual references for ActionScript code.

  10. Save the Flash document again.

At this point, the Flash document has a skeleton architecture (a blueprint) for your interactive functionality. Now you'll add some content to each section of the movie.

Note

You can find the main_100.fla document in the ch17/src folder of this book's CD-ROM.

Creating content for each area

In this section, you create navigation artwork for each area of the presentation. You also build some content for the video section.

  1. Resave the Flash file you modified in the last section as main_200.fla. Save the file in the src folder.

  2. Create a new layer named menu. Place this layer beneath the actions layer. Insert a keyframe on frame 10 of the menu layer.

  3. On frame 10 of the menu layer, use the Text tool to add a static text block with the text Introduction. For this example, I use the Miniml font hooge 05_53 at 12 points with bold formatting. Use the Properties panel to set these options. Place the text near the left edge of the Stage below the heading, as shown in Figure 17.7.

  4. Repeat Step 3 for the text Video Equipment, Audio Equipment, and Editing Software. Space these text blocks across the Stage beneath the heading, as shown in Figure 17.8. Again, all these text blocks should be on frame 10 of the menu layer. Later, you will convert each of these text blocks to a button symbol.

    Now, you create a graphic that lets the user know which section is currently active. To do this, you add a black square that will appear next to the appropriate text block. When the presentation starts, the black square will be next to the Introduction text. When the user navigates to the Video Equipment section, the black square will appear next to the Video Equipment section. Open the Library panel, and expand the graphics folder. There, you will find a graphic symbol named marker. You will use this symbol in a moment.

    Use the Text tool to add the Introduction text to the Stage.

    Figure 17.7. Use the Text tool to add the Introduction text to the Stage.

    Add text that describes each section of the presentation.

    Figure 17.8. Add text that describes each section of the presentation.

  5. Create a new layer on your Main Timeline (that is, Scene 1), and name it marker. Place this layer underneath the menu layer.

  6. On frame 10 of the marker layer, insert a keyframe. Drag the marker symbol from the Library panel to the Stage. Position the instance of the marker to the left of the Introduction text, as shown in Figure 17.9.

  7. Insert another keyframe (F6) on frame 20 of the marker layer — make sure you do not insert empty keyframes. Move the instance of the marker at frame 20 to the left of the Video Equipment text, as shown in Figure 17.10.

  8. Repeat Step 7 from frames 30 and 40 of the marker layer, moving the marker instance to the left of the Audio Equipment and Editing Software text, respectively. You now have the marker changing its position for all sections of the timeline.

    This marker designates the active section.

    Figure 17.9. This marker designates the active section.

    When the user goes to the Video Equipment section, the marker appears next to the Video Equipment text.

    Figure 17.10. When the user goes to the Video Equipment section, the marker appears next to the Video Equipment text.

Now you'll add a slide show of the video equipment that can be used for digital video production. This slide show will appear in the Video Equipment section of the presentation. For this, you create a Movie Clip symbol that has each product graphic on a separate keyframe.

  1. Create a new symbol by using Insert

    Main Timeline versus Scene Structure
  2. Flash CS5 automatically switches to Edit mode on the videoEquip timeline. Rename Layer 1 to items.

  3. Add keyframes to frames 2, 3, 4, 5, and 6 of the items layer. There are six items in the videoItems folder of the Library panel, and each item is put on its own keyframe.

  4. Move the playhead to frame 1 of the videoEquip timeline, and drag the dvTape Movie Clip symbol from the videoItemsfolder of the Library panel to the Stage. When an instance of the symbol is on the Stage, name the instance tape in the <Instance Name> field of the Properties panel.

  5. Continue moving the playhead to the next frame, dragging another item to the Stage for each frame. Place cameraLow on frame 2, cameraMid on frame 3, cameraHigh on frame 4, dvDeck on frame 5, and dvCable on frame 6. Make sure that you name each instance in the Properties panel, using the following names: camLow, camMid, camHigh, deck, and cable. When you're finished, press the < and > keys to review your frames. Check Figure 17.11 to compare your work. You may want to center each graphic on the Stage by using the Align panel (Ctrl+K/

    Main Timeline versus Scene Structure
  6. Now you need to insert an actions layer for this Movie Clip symbol. Create a new layer, and rename it actions. Select frame 1 of the actions layer, and open the Actions panel. Add a stop action to make sure that the items don't automatically loop when the movie loads:

    stop();
  7. Return to the Main Timeline (Scene 1) by clicking the Scene 1 tab in the upper-left corner of the document window.

  8. Create a new layer, and rename it content. Place this layer underneath the marker layer. Insert a new keyframe on frame 20 of the content layer.

  9. Open the Library panel, and drag the videoEquip symbol from the library to the Stage. Place it just left of the center of the Stage, as shown in Figure 17.12. In the Properties panel, name this instance equip.

  10. Select frame 30 of the content layer, and press the F7 key. This inserts a blank keyframe. Now, the equip instance will show only in the Video Equipment area of the timeline.

  11. Save your Flash document.

Now you have some content in the Flash document. In the next section, you add navigation controls to the presentation.

You should have six filled keyframes on the item layers of the videoEquip timeline.

Figure 17.11. You should have six filled keyframes on the item layers of the videoEquip timeline.

The equip instance will be present only in the video section of the timeline.

Figure 17.12. The equip instance will be present only in the video section of the timeline.

Note

You can find the main_200.fla document in the ch17 folder of this book's CD-ROM.

Adding Navigation Elements to the Main Timeline

In the last section, you created a timeline for a digital video production presentation. You inserted content placeholders for the intro, video, audio, and software sections of the timeline, and you made a Movie Clip with video item graphics to place in the video section. However, the user has no way of actually getting to any section except the intro frame. In this section, you convert the text blocks in the menu to button instances, whose actions control the position of the playhead on the Main Timeline.

Creating text buttons for a menu

In this part of the exercise, you make menu buttons that enable the user to navigate to the different areas of the Flash movie.

  1. Resave the main_200.flafile as main_300.fla in the src folder.

  2. On the Main Timeline of the file, select frame 10 of the menu layer.

  3. With the Selection tool, select the Introduction text block. Press F8 to convert this text into a symbol. In the Convert to Symbol dialog box, name the symbol introButton. Assign it a Button type. Click the top-left corner of the Registration box, as shown in Figure 17.13.

    The introButton symbol settings

    Figure 17.13. The introButton symbol settings

  4. Select the button instance on the Stage, and at the top field of the Properties panel, type introBtn in the Instance name field. You will target the button in ActionScript 3.0 code you create later in this chapter. Naming your instances is a good habit to get into.

    Now you need to add a Hit state to the introButton timeline. By default, Flash CS5 uses the last frame of a Button symbol timeline for the Hit state, unless content is added to the Hit state keyframe.

  5. Double-click the introBtn instance on the Stage to switch to Edit mode.

  6. On the timeline of the introButton symbol, select the Hit frame of Layer 1. Press the F7 key to insert an empty keyframe.

  7. Click the Onion Skin Outlines button in the Timeline window toolbar. This enables you to view the previous frames of the introButton timeline, as shown in Figure 17.14.

  8. Select the Rectangle tool, and draw a filled rectangle that covers the same area of the Introduction text block. You can use any fill color because the user never sees the Hit state. Make sure you turn off the stroke, or delete the stroke after the shape is drawn. Your button's timeline should resemble the one shown in Figure 17.15.

  9. Select the shape you drew in Step 8, and press F8 to convert it to a graphic symbol named hitArea. As with the introButton symbol, make sure that the Registration icon is active in the top-left corner. You will reuse this shape for the other buttons in this section.

    Next you add an Over state to the introButton so that the user has a visual indication that it's an active button.

  10. Select the Over frame of Layer 1, and press F6. This copies the contents of the previous keyframe into the new one. Select the Introduction text block with the Selection tool, and change the fill color to a shade of blue such as #0099CC in the Tools panel or the Properties panel. You can also turn off Onion Skin Outlines at this point.

    Onion skinning enables you to align the contents of several keyframes accurately.

    Figure 17.14. Onion skinning enables you to align the contents of several keyframes accurately.

    The Hit state defines the "active" area of the button instance in the movie. When the user's mouse pointer enters this area, the Over frame of the button appears.

    Figure 17.15. The Hit state defines the "active" area of the button instance in the movie. When the user's mouse pointer enters this area, the Over frame of the button appears.

  11. Return to the Main Timeline (that is, Scene 1) of your document, and save your Flash document. Choose Control

    The Hit state defines the "active" area of the button instance in the movie. When the user's mouse pointer enters this area, the Over frame of the button appears.

    Now you add ActionScript to the movie to enable interactivity with the introBtn instance. To aid the maintenance of ActionScript code for a project, you can create a separate ActionScript file (.as) to hold the code and use an include directive in the Flash document (.fla) to reference the external code.

  12. Choose File

    The Hit state defines the "active" area of the button instance in the movie. When the user's mouse pointer enters this area, the Over frame of the button appears.

    Tip

    One of the visual benefits to using an ActionScript file is that you have a much larger document window to write your ActionScript code. With an ActionScript file, you do not use the Actions panel to insert ActionScript code. You can also easily switch to an ActionScript file from another document that is open in Flash CS5.

    The New Document dialog box

    Figure 17.16. The New Document dialog box

  13. Choose File

    The New Document dialog box
  14. In the ActionScript file, type the following code. Do not type the

    The New Document dialog box
    //SimpleButton introBtn;
    
    import flash.events.MouseEvent;
    import flash.display.SimpleButton;
    
    introBtn.addEventListener(MouseEvent.CLICK, onMenuClick);
    
    function onMenuClick(evt:MouseEvent):void {
       var btn:SimpleButton = evt.currentTarget as SimpleButton;
       var frame:String = btn.name.substring(0, 
    The New Document dialog box
    btn.name.indexOf("Btn")); this.gotoAndStop(frame); }

    The first line of code tells the Flash CS5 authoring environment to display the code hints of the SimpleButton class for the introBtn instance. In ActionScript 3.0, a button symbol belongs to the SimpleButton class.

    The import statements tell the ActionScript compiler to reference the MouseEvent and SimpleButton classes that are part of the intrinsic Flash Player classes.

    The introBtn.addEventListener() line of code tells the introBtn instance to trigger a function named onMenuClick whenever the user's mouse clicks the introBtn instance. The click event is designated by MouseEvent.CLICK.

    The function named onMenuClick processes the mouse click event. The first line of code within the function retrieves a reference to the button broadcasting the event. Here, the reference named btn refers back to the introBtn instance. The second line of code determines which frame the Flash movie should now show by examining the button's name. The introBtn instance (btn.name) contains the name of the frame to which it belongs, intro. The variable named frame is then passed to a gotoAndStop() action which moves the playhead on the Main Timeline to the proper frame label.

  15. Save the main_menu.asfile, and switch back to the main_200.fla document.

  16. On the Main Timeline, create a new layer named menu actions, and place this layer above the existing actions layer.

  17. Insert an empty keyframe (F7) on frame 10 of the menu actions layer. Select this frame and open the Actions panel (F9,/Option+F9). In the Script pane, type the following line of code. The include directive tells the ActionScript compiler to grab the contents of the main_menu.as file whenever you test or publish the Flash movie (.swf):

    include "actionscript/includes/main_menu.as";

    To make sure that you've typed the path correctly, click the Check Syntax button (designated by a blue check mark) in the toolbar of the Actions panel. If the Output panel reports any errors, make sure that you saved main_menu.as in the location stated in Step 15.

    If you test your movie at this point, your introBtn instance won't do anything — the playhead already stops on the intro frame label when the movie starts.

  18. Add a button for each section on the site. Repeat Steps 3@nd10 for each section name in your movie. Note that you should reuse the hitArea graphic symbol from Step 9 for the remaining buttons — use the Free Transform tool to size each new instance of hitArea to match the size of the text block in the button symbol. You should end up with four named button instances on the Stage: introBtn, videoBtn, audioBtn, and softwareBtn.

    Tip

    When you're finished making all the buttons, make a folder in the Library panel named buttons, and move the button symbols and the hitArea graphic into the new folder.

  19. Go back to the main_menu.as file, and create additional listeners for the new button instances, as shown in the following code:

    //SimpleButton introBtn;
    //SimpleButton videoBtn;
    //SimpleButton audioBtn;
    //SimpleButton softwareBtn;
    
    import flash.events.MouseEvent;
    import flash.display.SimpleButton;
    
    introBtn.addEventListener(MouseEvent.CLICK, onMenuClick);
    videoBtn.addEventListener(MouseEvent.CLICK, onMenuClick);
    audioBtn.addEventListener(MouseEvent.CLICK, onMenuClick);
    softwareBtn.addEventListener(MouseEvent.CLICK, onMenuClick);
    function onMenuClick(evt:MouseEvent):void {
       var btn:SimpleButton = evt.currentTarget as SimpleButton;
       var frame:String = btn.name.substring(0, 
    The New Document dialog box
    btn.name.indexOf("Btn")); this.gotoAndStop(frame); }
  20. Save the main_menu.as file.

  21. Save your Flash document (.fla file) as main_300.fla in the src folder and test it (Ctrl+Enter/

    The New Document dialog box

Note

You can find the main_300.fla document in the ch17/src folder of this book's CD-ROM. The completed main_menu.as file is located in the ch17/src/actionscript/includes folder.

When you test your Flash movie, you should be able to click each button to go to each area of the movie — you should see the square marker move to each category name when you click the name. If a button isn't functioning, double-check the code in the menu_actions.as file. Make sure that each button instance is named in the Properties panel. In the next section, you add buttons to the videoEquip Movie Clip symbol so that the user can browse the pictures of the video items.

Browsing the video items

In this section, you go inside the videoEquip symbol and add some navigation buttons for the video items.

  1. Resave the main_300.fla file as main_400.fla.

  2. From the Main Timeline, double-click the equip instance on frame 20 of the content layer. Flash CS5 switches to Edit mode.

  3. Make a new layer on the videoEquip timeline, and rename the layer buttons. Place this layer below the actions layer.

  4. Open the Buttons Library (Window

    Browsing the video items
  5. With the circle button — next instance selected, press Ctrl+D (

    Browsing the video items
  6. Select both arrow buttons, and align them horizontally to each other by using the Align panel. Insert some descriptive text next to the instances, as shown in Figure 17.17.

    Add text to the buttons to describe their functionality.

    Figure 17.17. Add text to the buttons to describe their functionality.

    As discussed in the last section, you can create an external ActionScript file (.as file) to contain code for your Flash document. Start by replacing the existing stop() action on frame 1 of the videoEquip timeline with an include directive pointing to an ActionScript file.

  7. Select frame 1 of the actions layers, and open the Actions panel (F9/Option+F9). Delete the stop(); action, and type the following line of code:

    include "actionscript/includes/video_equipment.as"

    You create this new ActionScript file in the next step.

  8. Create a new ActionScript file (File

    Add text to the buttons to describe their functionality.
  9. In the new script file, type the following code. This code uses the same event, MouseEvent.CLICK, as the main menu buttons. Here, the onPrevClick() and onNextClick() functions act as listeners, sending the Movie Clip timeline to the previous or next frame, respectively:

    //SimpleButton prevBtn;
    //SimpleButton nextBtn;
    
    import flash.events.MouseEvent;
    
    prevBtn.addEventListener(MouseEvent.CLICK, onPrevClick);
    nextBtn.addEventListener(MouseEvent.CLICK, onNextClick);
    
    stop();
    
    function onPrevClick(evt:MouseEvent):void {
       this.prevFrame();
    }
    
    function onNextClick(evt:MouseEvent):void {
       this.nextFrame();
    }
  10. Save the video_equipment.asfile, switch back to your Flash document (.fla file), and test it by choosing Control

    Add text to the buttons to describe their functionality.

You can enhance your presentation by adding information in the videoEquip Movie Clip symbol. In the next section, you add a scrolling text window that displays descriptions of the video items.

Note

You can find the main_400.fla document in the ch17/src folder of this book's CD-ROM.

The topic of Flash usability has received a lot of press, particularly because many Flash interfaces are considered experimental or nonintuitive to the average Web user. Since December 2000, Adobe has maintained a special usability section in its Web site. You can read usability tips and view examples of interface design at www.adobe.com/devnet/flash/testing_usability.html.

Closely related to usability is accessibility: How easily can someone with a disability access the content within your Flash movie? I show you Flash movie accessibility options in the final section of this chapter.

Text Scrolling with the TextArea Component

Continuing from the previous Flash movie example with the digital video production presentation, you learn how to create basic scrolling text by using the TextArea component in Flash CS5. You can scroll text in Flash files (ActionScript 3.0) with either the UIScrollBar or the TextArea component. I demonstrate the use of the TextArea component for one item in the videoEquip symbol to get you started.

  1. Resave the main_400.flafile as main_500.fla.

  2. In the Flash document you created from the previous section, double-click the equipinstance on the Stage, at frame 20 of the content layer. Flash CS5 switches to Edit mode.

  3. Add a new layer, and rename it infoArea. Move this layer beneath the buttons layer, and select frame 1 of the infoArea layer. Now, open the Components panel (Ctrl+F7/

    Text Scrolling with the TextArea Component
  4. Use the Free Transform tool to stretch the component instance. This instance should accommodate several lines of text19. The size of the instance should match the size of the text area you want to appear in the scrolling text window. In the Properties panel, name the TextArea instance infoArea.

  5. Open the Properties panel, and expand the COMPONENT PARAMETERS section. With the infoArea instance selected on the stage, change the editable setting to false; the user should not be able to change the contents of the text field at runtime. Your videoEquip timeline should resemble Figure 17.18.

    Now, you'll need to supply some text to the infoArea instance. You can specify text directly in the text or htmlText parameter of the instance in the Properties panel, but for this project you'll learn how to format HTML text that is assigned in ActionScript to the TextArea component. Open the item_1.rtf document in a text editor such as WordPad or TextEdit. This file is located in the ch17/src/text folder of this book's CD-ROM. Now, open the item_1_formatted.txt document on the CD-ROM, and compare it to the item_1.rtf version. (You may want to enable word wrapping in your text editor so that you can see all the text in the TXT file.) You'll notice that all the text in the TXT file is specified in one continuous nonbreaking line. Moreover, any carriage returns in item_1.rtf have been replaced with <br/> tags in the TXT version. Some characters, such as the double quotes around the word "data," have been escaped in the TXT file — that is, the character is preceded by a backslash ( ). These special formatting characters ensure that ActionScript correctly displays the text.

  6. Select all the text in the item_1_formatted.txt file, and copy it. Later in this exercise, you'll paste the text into your own ActionScript code.

  7. On the videoEquip timeline, create a new layer and rename it actions - text. Place this layer below the existing actions layer.

  8. Select frame 1 of the actions - text layer, and open the Actions panel (F9/Option+F9). Here, you set a variable named info to the text to be displayed in the TextArea instance. In the Script pane, type the following code:

    info = "";
  9. Between the pair of double quotes you typed in Step 8, paste (Ctrl+V/

    Text Scrolling with the TextArea Component
    This text field displays the text associated with the first video item.

    Figure 17.18. This text field displays the text associated with the first video item.

    The Actions panel displaying the code to assign text to the TextArea component

    Figure 17.19. The Actions panel displaying the code to assign text to the TextArea component

  10. After the semicolon (;) at the end of the code you created in Steps 8 and 9, press Enter to start a new line of code. Type the following code:

    updateText(info);

    You define the updateText() function in the next step. This function processes the text stored in the info variable and displays it in the infoArea instance.

  11. Reopen (or switch back to) the video_equipment.as file you created in the last section. Add the new code shown in bold in the following code block:

    //SimpleButton prevBtn;
    //SimpleButton nextBtn;
    //TextArea infoArea;
    
    import flash.events.MouseEvent;
    
    prevBtn.addEventListener(MouseEvent.CLICK, onPrevClick);
    nextBtn.addEventListener(MouseEvent.CLICK, onNextClick);
    
    var info:String;
    
    stop();
    
    function onPrevClick(evt:MouseEvent):void {
       this.prevFrame();
    }
    
    function onNextClick(evt:MouseEvent):void {
       this.nextFrame();
    }
    
    function updateText(val:String):void {
       infoArea.htmlText = val;
       infoArea.verticalScrollPosition = 0;
    }

    This new code declares the info variable as a String variable, which can store text information. The updateText() function processes String data passed to it, setting the htmlText property of the infoArea instance to the new HTML text passed into the function. The vertical scrollbar's scroller is reset to the top of the scrollbar, if the amount of text requires a vertical scrollbar to appear.

  12. Save the video_equipment.asfile, and switch back to the Flash document (.fla file). Test the Flash document (Ctrl+Enter/

    The Actions panel displaying the code to assign text to the TextArea component

    Now, you're ready to set up the text for the second item on the videoEquip timeline.

  13. Select frame 2 of the actions - text layer, and press F7 to insert an empty keyframe. Add the same actions and text as shown in Steps 8 and 10, but this time, copy and paste the text from the item_2_formatted.txt file (located in the ch19/src/text folder of this book's CD-ROM).

  14. Save your Flash document (.fla file) and test it (Ctrl+Enter/

    The Actions panel displaying the code to assign text to the TextArea component
  15. Repeat Step 13 for frames 3, 4, 5, and 6 of the actions - text layer. When you are finished, you should have six separate action keyframes, one per item on the timeline.

  16. Save your Flash document again, and test it (Ctrl+Enter/

    The Actions panel displaying the code to assign text to the TextArea component

The next step in real production would be to finesse the artwork and to add transitional effects between each video item. The next section shows you how to add a custom Fade component that I created for your use in this exercise.

Note

You already added the ActionScript code in Step 11 to reset the scroll bar's position for each new item.

The verticalScrollPosition property controls the vertical position of the scroller. Setting it to zero resets the position to the top. So, if the user scrolls to the bottom of one description and presses the Next button, the next item's description reads from the top.

Note

You can find the completed document, main_500.fla, in the ch17/src folder of this book's CD-ROM. You can also find the finished video_equipment.as file in the ch17/src/actionscript/includes folder.

Using the Custom BlurFader Component

So far, much of the material and artwork used in this presentation could have been accomplished with a traditional HTML page layout in Adobe Dreamweaver with GIF or JPEG graphics. In this section, you add a fade effect to each of the video items in the videoEquip symbol. I created a custom component that can be applied to any Movie Clip instance on the Stage. This component fades a Movie Clip instance in or out, based on settings in the Component Inspector panel. To see this fade effect in action, open the main.swf file from the ch17/deploy folder in Flash Player 10. When you go to the Video Equipment section, each item fades and blurs in. In other words, the alpha of each Movie Clip instance animates from 0 to 100 percent while the blur value gradually decreases.

The BlurFader component snaps to Movie Clip instances. Because I built the component for you, you won't find the BlurFader component in the Component panel along with the Flash CS5 components. The BlurFader component is located in the starter document's library and has been saved in each version of the main_ document that you created in previous sections. Here's how to add the BlurFader component to the video items in the videoEquip symbol:

  1. Open your saved Flash document from the previous section, and resave the file as main_600.fla.

  2. On frame 20 of the content layer, double-click the equip instance on the Stage to edit the symbol.

  3. Select frame 1 of the items layer, and open the Library panel. Drag the BlurFader component to the tape instance on the Stage. When you release the mouse button, the BlurFader component should snap to the top-left corner of the tape instance, as shown in Figure 17.20. I made a custom icon for this BlurFader component: a little gradient box with the text BF. Select the BlurFader instance and name it bf_1 in the Properties panel.

    Note

    The BF icon does not show up in the actual Flash SWF file — it appears only in the authoring environment.

    The BlurFader component snaps to the top-left corner of the Movie Clip instance.

    Figure 17.20. The BlurFader component snaps to the top-left corner of the Movie Clip instance.

  4. You can view the default settings for the BlurFader component instance in the Properties panel. Select the component instance at the top-left corner of the tape instance, and look in the COMPONENT PARAMETERS section of the Properties panel This component has three options, as shown in Figure 17.20: Direction (in to fade in the targeted instance, out to fade out the targeted instance), Duration (how long the transition should last, in seconds), and Target Clip (the Movie Clip instance that the BlurFader component instance has snapped to).

  5. Save the Flash document, and test it (Ctrl+Enter/

    The BlurFader component snaps to the top-left corner of the Movie Clip instance.
  6. Repeat Step 3 for the other Movie Clip instances on frames 2, 3, 4, 5, and 6 of the items layer. Make sure that you name each new instance of the BlurFader component, using the frame number as a suffix, such as bf_2, bf_3, and so on. Otherwise, the blur and fade effect does not execute on the new items.

  7. Save the Flash document again, and test it. After you click the Video Equipment button, click the Next button. Each video item fades into the Stage.

If you want to use the BlurFader component in other Flash documents that use ActionScript 3.0, simply drag the BlurFader component from one library to another document's library. Alternatively, you can copy and paste the BlurFader component instance from one document to another. Try different Duration values for the BlurFader component (in the Component Inspector panel) to see how the fade animation is affected in the Flash movie.

Note

The BlurFader component adds about 2KB to the file size of your Flash movie file (.swf).

Note

You can find the completed document, main_600.fla, in the ch17/src folder of this book's CD-ROM.

Making the Movie Accessible

In the final section of this chapter, I show you how to add accessibility information to your Flash presentation. As I mention earlier in this chapter, screen readers on the Windows operating system, working in concert with the Flash Player 6 or later ActiveX control, can read aloud the content inside of Flash movies. Window-Eyes from GW Micro was engineered to work with Flash Player 6 or later through the use of MSAA (Microsoft Active Accessibility) technology. As of this writing, Window-Eyes is one of a limited number of screen readers capable of accessing Flash content.

Note

You can download a demo version of Window-Eyes for the Windows operating system at www.gwmicro.com. This version works only for 30-minute durations — you need to restart your computer to initiate a new session.

I recommend that you review the Accessibility information in the Flash CS5 Help panel. Choose the Help

Making the Movie Accessible

Note

Since Flash MX 2004, Adobe has added accessibility support to the authoring environment as well. This feature enables designers and developers with disabilities to more easily use Flash to author Flash movies. To find out more information about this feature, search with the term "accessibility" in the Help panel.

Screen readers access information within the Flash movie differently, depending on the features of the specific screen reader. Here I discuss accessibility options as they relate to Window-Eyes. You will add some content to the Introduction section of the presentation that Window-Eyes can read aloud.

  1. Resave the last Flash document you created in the previous section as main_700.fla.

  2. Insert an empty keyframe at frame 10 of the content layer on the Main Timeline (that is, Scene 1).

  3. On frame 10 of the content layer, drag an instance of the TextArea component from the Components panel to the left side of the Stage. In the Component Inspector panel, name this instance infoArea. Change the editable setting to false.

  4. Open the introduction_formatted.txtdocument in the ch17/src/textfolder of this book's CD-ROM. Copy the text in this document. Select the infoArea instance in your Flash document, and paste the copied text into the htmlText setting of the Component Inspector panel, as shown in Figure 17.21.

    The TextArea component can display HTML formatted text in the authoring environment. The screen reader can read aloud this text field's contents.

    Figure 17.21. The TextArea component can display HTML formatted text in the authoring environment. The screen reader can read aloud this text field's contents.

  5. With frame 10 of the content layer active, drag an instance of the cameraHigh Movie Clip symbol (located in the videoItems folder) from the Library panel to the Stage. In the Properties panel, change the alpha of this instance to 30 percent. Name the instance camHigh as well.

    Now you will use the Accessibility panel to add information to specific elements in the Introduction section of the presentation. You can open the Accessibility panel by choosing Window

    The TextArea component can display HTML formatted text in the authoring environment. The screen reader can read aloud this text field's contents.

    You can add general information about your Flash movie by deselecting all elements on the Stage (you can press the Esc key to do this quickly) and opening the Accessibility panel.

    The Make Movie Accessible option enables the screen reader to see elements inside the Flash movie. If this option is cleared, the screen reader cannot read any elements of the Flash movie.

    The Make Child Objects Accessible option enables the screen reader to access elements other than the current Name and Description in the Accessibility panel.

    Clear the Auto Label option. Auto Labeling tells Flash Player 6 or later to describe buttons and other elements by associating the closest text object to the element. For example, if you had some text underneath a Button instance, Auto Label would assign this text to the Button instance for the screen reader.

    The Name field enables you to assign a title to the Flash movie, and the Description field enables you to add a quick summary about the Flash movie. Window-Eyes reads the Name contents, but not the Description contents. Let's add some general information to the current Flash document.

  6. Deselect all the elements on the Stage, and open the Accessibility panel. Select the Make movie accessible and Make child objects accessible options, and clear the Auto label option. In the Name field, type the presentation's title: Digital Video Production. In the Description field, type the following text: A primer for digital video equipment and accessories. (See Figure 17.22.)

  7. Now select the Introduction button on frame 10 of the menu layer. In the Accessibility option, enter the options shown in Figure 17.23. Note that you do not assign a keyboard shortcut description for this example. The Name and Description for this button are read after the general information you added in the previous step. Window-Eyes says the word "button" before it reads the name. For this example, Window-Eyes says, "Button. Introduction. Access the introduction section of the presentation."

    Note

    If you do want to have a keyboard shortcut read by the screen reader, then you should type the text for any modifier key or combination including the + character, such as Ctrl+E. You also must add ActionScript to the movie to enable the key press that you described in the Accessibility panel.

    The Accessibility panel controls options for the Flash movie and its elements.

    Figure 17.22. The Accessibility panel controls options for the Flash movie and its elements.

    Window-Eyes can read the Name and Description contents for buttons.

    Figure 17.23. Window-Eyes can read the Name and Description contents for buttons.

  8. Repeat Step 7 for each button instance in the menu layer.

  9. Select the infoArea instance on frame 10 of the content layer, and make sure that the Make movie accessible and Make child objects accessible check boxes are selected in the Accessibility panel. It is not necessary to add a description to this text field — the text inside of the field is read automatically by the screen reader.

  10. Select the camHighinstance on frame 10 of the content layer, and make sure that the Make child objects accessible and Make object accessible options are not selected in the Accessibility panel. Not all elements need to be read by the screen reader, and this graphic does not need to be revealed to visually impaired users.

  11. Save your Flash document, and preview it in Internet Explorer for Windows. Make sure that the Window-Eyes application is active. As soon as the movie loads into the browser, Window-Eyes reads the information for the movie and then reads the name and descriptions of the buttons. Then it reads the text inside of the description text field. After Window-Eyes reads the last Flash element, it speaks the word "bottom," indicating that the end of the Web page has been reached. If you add body text to the HTML document, Window-Eyes reads that text as well.

Note

You can find the completed Flash presentation, main_700.fla, in the ch17/src folder of this book's CD-ROM. This document contains the first two sections of the presentations — on your own, try adding your content to the remaining sections by using techniques you learned in this chapter.

You can continue to add more accessibility information to other elements in the Flash document. You can even add information to elements within Movie Clip symbols. Try adding descriptions to the buttons inside of the videoEquip symbol.

Note

Screen reader technology can interface only with Flash movies played by the Flash Player 6 or later ActiveX control. Screen readers cannot access Flash movies played by the stand-alone Flash Player 6 or later.

Summary

  • Before you can start to create an interface in Flash, you need to have a plan for your Flash movie timeline. Create an organizational chart outlining the sections of the presentation.

  • Determine your Flash movie properties (frame size, frame rate, and background color) before you undergo production in Flash.

  • If you don't have final art for a Flash production, you can still create a functional prototype of the presentation by using placeholder graphics. When the final artwork is ready, replace the placeholder graphics with the final artwork.

  • You can create simple slide shows or product catalogs by using sequential keyframes and buttons with nextFrame() and prevFrame() actions.

  • The Hit area of a text-based Button symbol should always be defined with a solid shape.

  • You can achieve basic text scrolling by adding the TextArea component to your Flash movie.

  • You can apply time-based alpha and blur effects to artwork with the custom BlurFader component.

  • You can add accessibility information to Flash movies. Windows-based screen readers designed to work with Flash Player 6 or later, such as GW Micro's Window-Eyes, can read this information.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset