MACROMEDIA FLASH MX 2004-LEARNING FLASH Manual

Summary of FLASH MX 2004-LEARNING FLASH

  • Page 1

    Learning flash.

  • Page 2

    Trademarks add life to the web, afterburner, aftershock, andromedia, allaire, animation powerpack, aria, attain, authorware, authorware star, backstage, bright tiger, clustercats, coldfusion, contribute, design in motion, director, dream templates, dreamweaver, drumbeat 2000, edje, ejipt, extreme 3d...

  • Page 3: Contents

    3 contents introduction: learning macromedia flash mx 2004 . . . . . . . . . . . . . . . . . . . 9 additional resources for learning flash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 chapter 1: create a document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....

  • Page 4

    4 contents chapter 3: write scripts with actionscript . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 set up your workspace. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 create an instance of a symbol . . . . . . . . . . . . . . . . . . . . ...

  • Page 5

    Contents 5 align objects using the property inspector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 align objects using the grid and arrow keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....

  • Page 6

    6 contents chapter 10: add static, input, and dynamic text . . . . . . . . . . . . . . . . . . . . . . . 77 set up your workspace. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 create an expanding-width text block . . . . . . . . . . . . . . . . . . . ....

  • Page 7

    Contents 7 chapter 13: add interactivity with actionscript . . . . . . . . . . . . . . . . . . . . . . . . 97 set up your workspace. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 name button instances . . . . . . . . . . . . . . . . . . . . . . . . . . ...

  • Page 8

    8 contents.

  • Page 9: Introduction

    9 introduction learning macromedia flash mx 2004 learning flash overview macromedia flash mx 2004 and macromedia flash mx professional 2004 provide everything you need to create and deliver rich web content and powerful applications. Whether you’re designing motion graphics or building data-driven a...

  • Page 10

    10 introduction: learning macromedia flash mx 2004 where to start if you are new to flash, start with the “getting started with flash” chapter in help (help > help > using flash > getting started with flash) to help you become familiar with flash before proceeding to the flash lessons. To complete t...

  • Page 11

    Additional resources for learning flash 11 using the help panel the updatable help panel provides access to information on how to use flash. For more information about the help panel, see the following sections. Accessing help the tabs in the help panel—help and how do i—contain the full set of user...

  • Page 12

    12 introduction: learning macromedia flash mx 2004 updating the help panel the update feature allows you to update your help system with new and revised documentation, including procedures and lessons. You can click the update button to see if new information is available. Additionally, if you see a...

  • Page 13: Chapter 1

    13 chapter 1 create a document you’re about to experience the power of macromedia flash mx 2004 and macromedia flash mx professional 2004. You’ll see how, in a few minutes, you can create a compelling web experience that combines video, text, graphics, and media control behaviors. In the process, yo...

  • Page 14

    14 chapter 1: create a document take a tour of the user interface first you’ll open the starting fla file that you’ll use to complete this lesson. Each lesson includes one start file, and a finished file that demonstrates how the fla file should appear upon completion of the lessons. 1. To open your...

  • Page 15

    Take a tour of the user interface 15 use tools to create flash content the white rectangular stage area is where you can arrange objects as you wish them to appear in your published file. Note: in windows operating systems, you can open several documents at once and use document tabs, above the stag...

  • Page 16

    16 chapter 1: create a document • move the mouse pointer over the area that separates the stage from the timeline. When the resizing handle appears, drag up or down slightly to resize the timeline as necessary. The playhead (the red indicator line) is on frame 1 in the timeline. The keyframes are de...

  • Page 17

    Add video 17 view the library panel flash content that you import or that is a symbol is stored in your library panel. To learn more about symbols and instances, select help > how do i > basic flash > create symbols and instances. • to view the library panel, select window > library. We’ve already i...

  • Page 18

    18 chapter 1: create a document view object properties when you add an object to the stage, you can select it, then view and change its properties in the property inspector. The type of object selected determines which properties appear. For example, if you select a text object (not a text graphic, ...

  • Page 19

    Test the document 19 7. In the rewind video dialog box, select video. 8. In the number of frames to step back text box, enter 20. The number of frames to step back text box indicates how many frames the playhead should move back when the user clicks the rewind button. Note: additional video control ...

  • Page 20

    20 chapter 1: create a document find help the lessons provide an introduction to flash, and suggest ways that you can use features to create exactly the kind of document required. For comprehensive information about a feature, procedure, or process described in the lessons, see the help tab of the h...

  • Page 21: Chapter 2

    21 chapter 2 create accessible flash content with knowledge of a few design techniques and accessibility features in macromedia flash mx 2004 and macromedia flash mx professional 2004, you can create flash content that is accessible to all users, including those with disabilities. This lesson demons...

  • Page 22

    22 chapter 2: create accessible flash content set up your workspace first, you’ll open the start file for the lesson and set up your workspace to use an optimal layout for taking lessons. 1. To open your start file, in flash select file > open and navigate to the file: ■ on windows 2000 or xp, brows...

  • Page 23

    Specify that screen readers ignore elements in your document 23 provide a document title and description in the accessibility panel for the document, you can enter a name and description for your document for screen readers. • in the name text box, enter trio zx2004. In the description text box, ent...

  • Page 24

    24 chapter 2: create accessible flash content 1. On the stage, click the car, which is the safety_mc movie clip instance. 2. In the accessibility panel, deselect make child objects accessible. In the name text box, enter trio zx2004 animation. In the description text box, enter animation that includ...

  • Page 25

    Control the tab order and reading order 25 if you have flash mx professional 2004, you can follow this procedure to create a tab order using the accessibility panel: 1. With the accessibility panel open, select the logo_mc instance at the top of the stage. In the accessibility panel, enter 1 in the ...

  • Page 26

    26 chapter 2: create accessible flash content follow this procedure to control the tab order and reading order using actionscript: 1. In the timeline, select frame 1 of the actions layer. 2. In the actions panel (window > development panels > actions), view the actionscript that creates the tab inde...

  • Page 27: Chapter 3

    27 chapter 3 write scripts with actionscript the actionscript language that is part of macromedia flash mx 2004 and macromedia flash mx professional 2004 offers designers and developers a variety of benefits. With actionscript you can control document playback in response to events such as elapsed t...

  • Page 28

    28 chapter 3: write scripts with actionscript set up your workspace first, you’ll open the start file for the lesson and set up your workspace to use an optimal layout for taking lessons. 1. To open your start file, in flash select file > open and navigate to the file: ■ on windows 2000 or xp, brows...

  • Page 29

    Name button instances 29 4. Drag the map_skewed movie clip on the stage again so that the align guides appear. Use the guides to align the movie clip to the top and left edges of the gps screen. Note: if you make an error in placement, either drag the movie clip again, or press control+z (windows) o...

  • Page 30

    30 chapter 3: write scripts with actionscript initialize the document applications have an initial state that specifies how the content first appears to users. You initialize properties and variables in the first frame of a document. You’ll specify that the map movie clip not be visible when the swf...

  • Page 31

    Write a function for a button 31 later in this lesson, you’ll use flash features that allow you to test your syntax. Locate actionscript reference documentation during authoring, if you’d like additional information about the actionscript that you enter, you can select the action in the actions tool...

  • Page 32

    32 chapter 3: write scripts with actionscript 4. In the script pane, press the spacebar and type the following: = function(){ the line of code that you just completed should appear as follows: this.Onbutton_btn.Onrelease = function(){ you already know how to select objects in the insert target path ...

  • Page 33

    Summary 33 //function to hide animation this.Offbutton_btn.Onrelease = function(){ screen_mc._visible = false; }; check syntax and test your application as you learned earlier in this lesson, actionscript depends on correct syntax to execute properly. Flash offers a variety of ways for you to test y...

  • Page 34

    34 chapter 3: write scripts with actionscript.

  • Page 35: Chapter 4

    35 chapter 4 create an application the application that you’ll create in this lesson lets users view the cost of selecting multiple products. A calculate button then adds the total cost. You’ll learn how to accomplish the following tasks as you create the application: • copy input and dynamic text f...

  • Page 36

    36 chapter 4: create an application 2. Select file > save as and save the document with a new name, in the same folder, to preserve the original start file. Note: as you complete this lesson, remember to save your work frequently. 3. Select window > panel sets > training layout to modify your worksp...

  • Page 37

    Specify values for input text fields 37 1. Select file > publish settings. 2. On the flash tab of the publish settings dialog box, select actionscript 2.0 in the actionscript version pop-up menu, if it’s not already selected. 3. In the timeline, click the components layer to select it. 4. From the c...

  • Page 38

    38 chapter 4: create an application 3. Press enter or return and type the following two lines to set values of 0 for the other two qty fields: qty2_txt.Text = 0; qty3_txt.Text = 0; when you finish, the actionscript should appear as follows: //set initial values for the quantity text fields qty1_txt....

  • Page 39

    Write an event handler for the component 39 write an event handler for the component for your swf file to react to events such as a mouse click, you can use event handlers— actionscript associated with a particular object and event. You’ll use an on() event handler for the button component that calc...

  • Page 40

    40 chapter 4: create an application test your application you’ll test your application to ensure that it executes as expected. 1. Save your document and select control > test movie. 2. In the test version of your movie that appears in flash player, type numbers in the qty fields to see what appears ...

  • Page 41: Chapter 5

    41 chapter 5 work with layers in macromedia flash mx 2004 and macromedia flash mx professional 2004, layers are analogous to transparent sheets of acetate stacked on top of each other. In the areas of a layer that don’t contain content, you can see through to content on the layers below. Layers assi...

  • Page 42

    42 chapter 5: work with layers set up your workspace first, you’ll open the start file for the lesson and set up your workspace to use an optimal layout for taking lessons. 1. To open your start file, in flash select file > open and navigate to the file: ■ on windows 2000 or xp, browse to boot drive...

  • Page 43

    Lock a layer 43 select a layer you place objects, add text and graphics, and edit on the active layer. To make a layer active, you either select the layer in the timeline or select a stage object in the layer. The active layer is highlighted in the timeline, and the pencil icon indicates it can be e...

  • Page 44

    44 chapter 5: work with layers add and name a layer you’ll now add a layer, name the layer, and then add a graphic symbol to the layer. 1. In the timeline, click the car layer. 2. Click the insert layer button below the timeline. The new layer appears above the car layer and becomes the active layer...

  • Page 45

    Add a guide layer 45 add a mask layer using a mask layer provides a simple way to selectively reveal portions of the layer or layers below it. Masking requires making one layer a mask layer and the layers below it masked layers. You’ll use the rectangular shape on the stage to mask part of the road ...

  • Page 46

    46 chapter 5: work with layers delete a layer since you don’t really need the guide layer in your document, you’ll delete it. • in the timeline, with the notes layer selected, click the delete layer button. Summary congratulations on learning how to work with layers in flash. In just a few minutes, ...

  • Page 47: Chapter 6

    47 chapter 6 create a user interface with layout tools macromedia flash mx 2004 and macromedia flash mx professional 2004 offer a variety of ways to place objects precisely on the stage, letting you choose your preferred method. In this lesson, you’ll use layout tools to create a user interface. Spe...

  • Page 48

    48 chapter 6: create a user interface with layout tools set up your workspace first, you’ll open the start file for the lesson and set up your workspace to use an optimal layout for taking lessons. 1. To open your start file, in flash select file > open and navigate to the file: ■ on windows 2000 or...

  • Page 49

    Resize objects to match the stage size 49 5. On the stage, click the upper left corner of the text block and drag it to the intersection of the two guides. A small circle appears when the selection snaps to the guides. 6. If you want to remove the guides, select view > guides > clear guides. Change ...

  • Page 50

    50 chapter 6: create a user interface with layout tools 8. Click align left edge and align bottom edge. The bevel aligns to the bottom edge of the stage. 9. Close the library panel and the align panel. Specify snap alignment settings snapping offers a way of precisely placing an object on the stage ...

  • Page 51

    Snap objects to each other 51 5. While keeping the car centered with the body text (you should continue to see the center alignment guide), drag the auto in a straight line, toward the left of the stage, until the guide snaps at the 30-pixel border that you created previously. You’ve aligned the car...

  • Page 52

    52 chapter 6: create a user interface with layout tools 3. From the library panel, drag the nav graphic to any area of the stage below the blue banner, and then release the nav graphic. 4. Click the upper left corner of the nav graphic, then drag it so that a circular snap indicator appears. 5. With...

  • Page 53

    Summary 53 align objects using the grid and arrow keys you can use the grid to assist you in placing objects on the stage. 1. Select view > grid > show grid. The grid does not appear when you test or publish your document. Note: if you wanted to snap objects to the horizontal and vertical grid lines...

  • Page 54

    54 chapter 6: create a user interface with layout tools.

  • Page 55: Chapter 7

    55 chapter 7 draw in flash when you draw in flash, you create vector art, which is a mathematical representation of lines, curves, color, and position. Vector art is resolution-independent; you can rescale the art to any size or display it at any resolution without losing clarity. Additionally, vect...

  • Page 56

    56 chapter 7: draw in flash set up your workspace first, you’ll open the start file for the lesson and set up your workspace to use an optimal layout for taking lessons. 1. To open your start file, in flash select file > open and navigate to the file: ■ on windows 2000 or xp, browse to boot drive\do...

  • Page 57

    Rotate the shape 57 select options to create a polygon the polystar tool offers options that let you specify the number of sides in a polygon; you can also use options for the tool to create a star. You’ll specify that your polygon have six sides. 1. In the property inspector, with the polystar tool...

  • Page 58

    58 chapter 7: draw in flash use the cut-out feature when you create one shape on top of another on the same layer, and the two shapes are ungrouped, the shape on top “cuts out” the area of the shape underneath. You’ll create a circle within the hexagon, then cut out the circle. 1. Select view > snap...

  • Page 59

    Select and add a different fill color 59 copy strokes you can select and copy strokes, which you’ll do now to create the lower edge of the bolt. 1. With the selection tool, click anywhere on the stage or work area, away from an object, to deselect the shape. 2. Hold shift and click the three lines o...

  • Page 60

    60 chapter 7: draw in flash group the shape you can manipulate the stroke and fill of a shape as separate entities, as you did earlier, or you can group the stroke with the fill to manipulate the shape as a single graphic, which you’ll do now. 1. With the selection tool, drag around the shape to sel...

  • Page 61

    Summary 61 summary congratulations on learning how to use some of the various drawing tools in flash. In a few minutes, you learned how to accomplish the following tasks: • create a polygon • rotate a shape • cut out a shape within a shape • transform artwork • copy strokes • draw lines with the lin...

  • Page 62

    62 chapter 7: draw in flash.

  • Page 63: Chapter 8

    63 chapter 8 create symbols and instances a symbol is a reusable object, and an instance is an occurrence of a symbol on the stage. Repeated use of instances does not increase the file size and is a good part of a strategy for keeping a document file size small. Symbols also simplify editing a docum...

  • Page 64

    64 chapter 8: create symbols and instances 2. Select file > save as and save the document with a new name, in the same folder, to preserve the original start file. As you complete this lesson, remember to save your work frequently. 3. Select window > panel sets > training layout to configure your wo...

  • Page 65

    Modify a symbol 65 duplicate and modify an instance of a symbol once you’ve created a symbol, you can use instances of it repeatedly in your document. You can modify the following instance properties for an individual instance without affecting other instances or the original symbol: color, scale, r...

  • Page 66

    66 chapter 8: create symbols and instances 3. Drag the middle-right sizing handle of the free transform tool slightly to the right, to stretch the symbol. 4. Click scene 1, above the timeline, to exit symbol-editing mode. Both instances of the symbol reflect the transformation. Create a movie clip s...

  • Page 67

    Summary 67 add an effect to the movie clip you can create an animation within a movie clip timeline, in symbol-editing mode, that plays independent of the main timeline. You’ll add an effect to the mcwheel symbol that will cause all instances of the symbol to spin. 1. With the selection tool, double...

  • Page 68

    68 chapter 8: create symbols and instances.

  • Page 69: Chapter 9

    69 chapter 9 add animation and navigation to buttons a button is a symbol that contains special frames for different button states, such as when the user’s mouse pointer is over the button or when the user clicks the button. When you select the button behavior for a new symbol, macromedia flash mx 2...

  • Page 70

    70 chapter 9: add animation and navigation to buttons set up your workspace first, you’ll open the start file for the lesson and set up your workspace to use an optimal layout for taking lessons. 1. To open your start file, in flash select file > open and navigate to the file: ■ on windows 2000 or x...

  • Page 71

    Change the hit area of a button 71 name a button instance as a best practice, name instances of symbols on the stage. Actionscript relies on the instance name to identify the object. • with the button that you created still selected, open the property inspector (window > properties). In the instance...

  • Page 72

    72 chapter 9: add animation and navigation to buttons 3. Select the hit frame (frame 4) of the hit area layer in the btnlogo timeline, and press f6 to add a keyframe. 4. In the tools panel, select the rectangle tool. The stroke and fill color are unimportant. On the stage, draw a rectangle that cove...

  • Page 73

    Add an action to a button 73 create animation for a button state you’ll create a movie clip within the over state of button 1, and then create a shape tween in the movie clip. The shape tween creates an effect that changes the color from gray to red. 1. On the stage, double-click button 1 to open it...

  • Page 74

    74 chapter 9: add animation and navigation to buttons 8. On the stage, move the pointer over the button and click the button. 9. Select control > enable simple buttons to deselect that feature. Add navigation to a button with behaviors, you can quickly add navigation to a button without having to kn...

  • Page 75

    Summary 75 summary congratulations on learning about buttons. In a few minutes, you were able to accomplish the following tasks: • create a button from grouped objects • name a button instance • view the hit area of a button • change the hit area of a button • align buttons • create animation for a ...

  • Page 76

    76 chapter 9: add animation and navigation to buttons.

  • Page 77: Chapter 10

    77 chapter 10 add static, input, and dynamic text macromedia flash mx 2004 and macromedia flash mx professional 2004 provide a variety of text features and options. This lesson introduces you to the three primary types of text you can add to a document. You can add static text for titles, labels, or...

  • Page 78

    78 chapter 10: add static, input, and dynamic text set up your workspace first, you’ll open the start file for the lesson and set up your workspace to use an optimal layout for taking lessons. 1. To open your start file, in flash select file > open and navigate to the file: ■ on windows 2000 or xp, ...

  • Page 79

    Create a fixed-width text block 79 create an expanding-width text block you can define the size of a text block, or you can use a text block that expands to fit the text you write. You’ll begin this lesson by simply adding text to a document. 1. Click in a blank area in the workspace to make sure no...

  • Page 80

    80 chapter 10: add static, input, and dynamic text 4. On the stage, drag your pointer over the area of the text 2 guide. An extendable one-line static text block has a round handle in the upper right corner, and a fixed-width static text block has a square handle. 5. Inside the text block that you c...

  • Page 81

    Copy a text field 81 add an input text field you can use an input text field to allow viewers an opportunity to interact with your flash application. For example, input text fields offer an easy way to create forms. In a later lesson (select help > how do i > basic actionscript > create a form with ...

  • Page 82

    82 chapter 10: add static, input, and dynamic text assign instance names to text fields an input text field on the stage is an instance of the actionscript textfield object, to which you can apply properties and methods. As a best practice, you should name text field instances so that you or others ...

  • Page 83

    Test the swf file 83 specify format options the format options dialog box allows you to specify margin and indentation settings for the text. 1. With the dynamic text field still selected on the stage, click format in the property inspector. 2. In the left margin text box, enter 5, and in the right ...

  • Page 84

    84 chapter 10: add static, input, and dynamic text check spelling flash mx 2004 and flash mx professional 2004 introduce new features that let you check spelling in most places where text occurs in your document, including text fields, layer names, and actionscript strings. To check spelling, you fi...

  • Page 85: Chapter 11

    85 chapter 11 create a timeline animation macromedia flash mx 2004 and macromedia flash mx professional 2004 provide powerful tools for creating animation. Most simple animation in flash is done using a process known as tweening. Tweening is short for “in between” and refers to filling in the frames...

  • Page 86

    86 chapter 11: create a timeline animation set up your workspace first, you’ll open the start file for the lesson and set up your workspace to use an optimal layout for taking lessons. 1. To open your start file, in flash select file > open and navigate to the file: ■ on windows 2000 or xp, browse t...

  • Page 87

    Create a shape tween 87 3. Use the selection tool to reposition the tire, if necessary. 4. With the selection tool still selected, in the tireanim layer, select frame 30. Then press f6 to insert a keyframe. 5. Select frame 15 and press f6 to add another keyframe. 6. With the playhead still on frame ...

  • Page 88

    88 chapter 11: create a timeline animation 3. With the playhead on frame 15, select the selection tool. Drag the tire shadow slightly up and to the right. 4. With frame 15 still selected, select the eyedropper tool in the tools panel, and then click the shadow object. 5. If the color mixer is not al...

  • Page 89

    Change the speed of the animation 89 4. Select the transformation center point (the small circle near the center of the movie clip) and drag it to the bottom of the tire. The center point snaps to the lower middle transform handle. 5. On the stage, drag the upper middle transform handle down to slig...

  • Page 90

    90 chapter 11: create a timeline animation change the acceleration and deceleration by default, tweened frames play at a constant speed. With easing, you can create a more realistic rate of acceleration and deceleration. Positive values begin the tween rapidly and decelerate the tween toward the end...

  • Page 91: Chapter 12

    91 chapter 12 create a presentation with screens (flash professional only) flash mx professional 2004 offers a new way, with slide screens, to create presentations. If you can imagine placing media on slide screens, adding nested slides that inherit media from other slides, and using the built-in co...

  • Page 92

    92 chapter 12: create a presentation with screens (flash professional only) the document opens in the flash authoring environment. 2. Select file > save as and save the document with a new name, in the same folder, to preserve the original start file. As you complete this lesson, remember to save yo...

  • Page 93

    Add content to a presentation slide 93 view screen properties you can view different properties for a slide, depending on where you select the slide. 1. In the screen outline pane, select the presentation thumbnail. The property inspector allows you to change the instance name, which is also the nam...

  • Page 94

    94 chapter 12: create a presentation with screens (flash professional only) add screen navigation behaviors to buttons when you open a new flash slide presentation, the document already includes functionality that lets users navigate between slide screens using the keyboard arrow keys. You’ll also a...

  • Page 95

    Add transition behaviors 95 select and move slides you can copy, cut, paste, and drag screens in the screen outline pane to change their order in the presentation. You’ll select three screens, cut them, and paste them so that they’re nested as children of the features slide. 1. In the screen outline...

  • Page 96

    96 chapter 12: create a presentation with screens (flash professional only) 4. To add the fly behavior, verify that the features slide is still selected. In the behaviors panel, click the add (+) button and select screen > transition from the menu. 5. In the transitions dialog box, select fly from t...

  • Page 97: Chapter 13

    97 chapter 13 add interactivity with actionscript macromedia flash mx 2004 and macromedia flash mx professional 2004 offer numerous ways to engage users with interactivity. Additionally, when you incorporate interactivity, you’re not limited to playing each timeline frame sequentially, which offers ...

  • Page 98

    98 chapter 13: add interactivity with actionscript set up your workspace first, you’ll open the start file for the lesson and set up your workspace to use an optimal layout for taking lessons. 1. To open your start file, in flash select file > open and navigate to the file: ■ on windows 2000 or xp, ...

  • Page 99

    Move between scenes 99 name button instances you’ll provide instance names for the buttons on the stage so that you can refer to the instance names in actionscript. 1. On the lower right side of the stage, select the button at the left. In the property inspector (window > properties), type goscene_b...

  • Page 100

    100 chapter 13: add interactivity with actionscript control the document with a stop() action when you test or publish a flash document that contains more than one scene, by default the scenes play linearly, in the order in which they appear in the scenes panel. You’ll use a stop() action for scene ...

  • Page 101

    Play a movie clip 101 play a movie clip you can configure your document to play a movie clip at runtime. Using the attachmovie() method, you can attach an instance of a movie clip in the library panel to the stage even though you have not placed an instance on the stage. With the attachmovie() metho...

  • Page 102

    102 chapter 13: add interactivity with actionscript note: for more information about the attachmovie() method, see attachmovie() in the flash actionscript language reference. Additionally, you can use the flash actionscript language reference for information about actionscript that allows you to man...

  • Page 103

    Summary 103 use a behavior to play an mp3 file when you want to add interactivity to your document with actionscript, you can often rely on behaviors to add the actionscript for you. You’ll use a sound behavior to play an mp3 file from the library. 1. In the library panel, right-click (windows) or c...

  • Page 104

    104 chapter 13: add interactivity with actionscript.

  • Page 105: Chapter 14

    105 chapter 14 create a form with conditional logic and send data you can create a form with conditional logic that allows the swf file to respond in different ways, depending on user interaction, and send the form data from the swf file to an external source. In this lesson, you will create a simpl...

  • Page 106

    106 chapter 14: create a form with conditional logic and send data note: the basicactionscript\finished_files folder contains completed versions of lesson fla files, for your reference. 2. Select file > save as and save the document with a new name, in the same folder, to preserve the original start...

  • Page 107

    Add an error message 107 add a submit button to the form the library panel contains a submit button symbol that you will add to the form. 1. From the library panel (window > library), drag the submit button to the stage and place it over the submiturl guide. 2. Drag the button or use the arrows keys...

  • Page 108

    108 chapter 14: create a form with conditional logic and send data add a confirmation message next, you’ll add a message to display when the user submits an entry in the text field. 1. In the dialog boxes layer, select frame 10. Right-click (windows) or control-click (macintosh) the selected frame a...

  • Page 109

    Add conditional logic for the submit button 109 add frame labels for navigation when the viewer presses the submit button, you want flash to jump to either the error message or the confirmation message, depending on what is entered in the text field. Labeling a frame helps you easily reference it in...

  • Page 110

    110 chapter 14: create a form with conditional logic and send data 11. Type gotoandstop("confirm") in the script pane. Press enter or return, and type }, then press enter or return again and type }; . Your script should appear as follows: //stops the playhead at frame 1 stop(); //adds conditional lo...

  • Page 111

    Summary 111 3. Type tryagain_btn.Onrelease = function(){ , then press enter or return. 4. Type gotoandstop(1); , then press enter or return and type } to complete the script. Test your swf file you’ll test your document by entering a url and checking whether it works as expected. 1. Select control >...

  • Page 112

    112 chapter 14: create a form with conditional logic and send data.

  • Page 113: Chapter 15

    113 chapter 15 work with objects and classes using actionscript 2.0 classes are the blueprint for objects in macromedia flash mx 2004 and macromedia flash mx professional 2004. All objects in flash have an underlying class; for example, all movie clips have a method called geturl , and geturl is def...

  • Page 114

    114 chapter 15: work with objects and classes using actionscript 2.0 ■ on macintosh, browse to macintosh hd/users/shared/application support/macromedia/ flash mx 2004/language/configuration/helppanel/howdoi/basicactionscript/ finished_files. 2. Select window > panel sets > training layout to configu...

  • Page 115

    Creating a custom class 115 modify your script you’ll modify your script to compensate for the zero indexing. 1. Add +1 to the value when you create currentmonth, and test your document to be sure the expected month number appears. That line of script should read as follows: var currentmonth:number ...

  • Page 116

    116 chapter 15: work with objects and classes using actionscript 2.0 in order to properly define a class in actionscript 2.0, you must surround all classes by the class keyword, and you must declare all variables in the constructor outside of the constructor. Following is an example: note: the follo...

  • Page 117

    Creating a custom class 117 build a custom class you’ll now build a new product class with getter and setter methods and create an object from the product class. 1. Create an actionscript file by doing one of the following: ■ if you’re using flash mx 2004 professional, select file > new > actionscri...

  • Page 118

    118 chapter 15: work with objects and classes using actionscript 2.0 } public function setid (id:number) :void { this.Id = id; } public function setprodname (prodname:string) :void { this.Prodname = prodname; } public function setdescription (description:string) :void { this.Description = descriptio...

  • Page 119

    About extending existing classes 119 3. Verify that you created the objects as follows: var handlebars:product = new product (1, "atb", "available in comfort and aero design"); var pedals:product=new product(0,"clipless pedals","excellent cleat engagement"); 4. Trace the description property of peda...

  • Page 120

    120 chapter 15: work with objects and classes using actionscript 2.0 extend the movieclip class to create a new class you’ll create a new class by extending the built-in movieclip class. 1. Create a new flash document and name it shape.Fla. 2. Using the drawing tools, draw a shape on the stage. With...

  • Page 121

    Summary 121 9. Define private methods in the class that use the existing movie clip methods, startdrag() and stopdrag() : class drag extends movieclip { function drag() { onpress=dodrag; onrelease=dodrop; } private function dodrag():void { this.Startdrag(); } private function dodrop():void { this.St...

  • Page 122

    122 chapter 15: work with objects and classes using actionscript 2.0