Macromedia Flash Design Application Using Action Script and

  • Slides: 40
Download presentation
Macromedia Flash Design & Application Using Action. Script and Creating Templates OBJ 7 -1

Macromedia Flash Design & Application Using Action. Script and Creating Templates OBJ 7 -1 Copyright 2003, Paradigm Publishing Inc.

Performance Objectives Ø Define the terms object-oriented programming, object, method, action, event, and parameters.

Performance Objectives Ø Define the terms object-oriented programming, object, method, action, event, and parameters. Ø List general guidelines for creating Action. Script in movies. Ø Switch between Normal mode and Expert mode in the Actions panel and describe the difference between the two modes. Ø Add actions to keyframes, buttons, and movie clips. Ø Use the goto and stop actions to control movie playback. Ø Add labels and comments to frames. Ø Create a preloader animation. Ø Perform a conditional test on a movie property. OBJ 7 -2 Copyright 2003, Paradigm Publishing Inc.

Performance Objectives Ø Create buttons to toggle the playback of a stream soundtrack on

Performance Objectives Ø Create buttons to toggle the playback of a stream soundtrack on and off. Ø Use the with action to target start and stop actions at a movie clip instance. Ø Use the get. URL action to open a Web page during a movie. Ø Use the fscommand action to control a projector window. Ø Create and use a Flash template. Ø Use the Movie Explorer. Ø List Web resources for learning more about Flash. Ø COMMANDS REVIEW OBJ 7 -3 Copyright 2003, Paradigm Publishing Inc.

Understanding Action. Script Concepts and Terms Ø Action. Script is a scripting language §

Understanding Action. Script Concepts and Terms Ø Action. Script is a scripting language § scripts are a series of commands that provide instruction to the computer § commands are generally carried out in sequence § generally easy to understand Ø Learning Action. Script involves: § learning the keywords § using proper syntax OBJ 7 -4 Copyright 2003, Paradigm Publishing Inc.

Object-Oriented Programming Ø Action. Script is an object-oriented scripting language § similar to Java.

Object-Oriented Programming Ø Action. Script is an object-oriented scripting language § similar to Java. Script Ø Classes are defined with a set of properties and methods § defines the object's characteristics and behavior § instances of a class are referred to as objects Ø Existing code can be reused § more efficient and easier to maintain OBJ 7 -5 Copyright 2003, Paradigm Publishing Inc.

Actions, Events, and Parameters Ø Actions § statements that instruct Flash on what to

Actions, Events, and Parameters Ø Actions § statements that instruct Flash on what to do with a target object § listed in the toolbox in the Actions panel Ø Events § an event can be a mouse movement, a key pressed on the keyboard, or the loading of a movie clip § the event triggers the action § actions applied to a button or movie clip instance execute when an event occurs Ø Parameters OBJ 7 -6 § also called arguments § provide the variable information for the action statement Copyright 2003, Paradigm Publishing Inc.

General Guidelines for Writing Action. Script Ø Before starting to write Action. Script code

General Guidelines for Writing Action. Script Ø Before starting to write Action. Script code you should have: § a clear definition of the goal of the movie § a flow chart diagramming the movie's actions § a plan as to which objects will require Action. Script statements Ø Use comments to document what is happening at key points Ø Focus on one section at a time until it is working correctly § then save as a separate version as a backup Ø Object and variable names should be descriptive labels § easily identify the element OBJ 7 -7 Copyright 2003, Paradigm Publishing Inc.

The Actions Panel in Normal Mode Flash assists you with the programming. The proper

The Actions Panel in Normal Mode Flash assists you with the programming. The proper syntax for each statement is inserted. Window, Actions or F 9 Step 1 Flash builds Step 2 Double-click the code for you. Add parameters if action in toolbox. the action has any. OBJ 7 -8 Copyright 2003, Paradigm Publishing Inc.

The Actions Panel in Expert Mode The parameters area is replaced with a larger

The Actions Panel in Expert Mode The parameters area is replaced with a larger Action. Script area. Check Syntax Show Code Hint show next code hint Step 1 Double-click action in toolbox. OBJ 7 -9 Flash does not build the statement for you. Use code hints to view available parameters for the current action. Step 2 Key parameters using proper syntax. Switching from Expert mode to Normal code causes Flash to check the syntax. Copyright 2003, Paradigm Publishing Inc.

Controlling Movie Playback OBJ 7 -10 Copyright 2003, Paradigm Publishing Inc.

Controlling Movie Playback OBJ 7 -10 Copyright 2003, Paradigm Publishing Inc.

Goto Ø Moves the playhead to a different frame in the Timeline Ø Destination

Goto Ø Moves the playhead to a different frame in the Timeline Ø Destination parameter can be specified using a frame number or a frame label § using frame labels is preferable since the label stays with the frame when editing Ø Includes two choices when it reaches the destination § Go to and Play § Go to and Stop OBJ 7 -11 Copyright 2003, Paradigm Publishing Inc.

On Ø Dimmed unless a button instance is active Ø Creates the event handler

On Ø Dimmed unless a button instance is active Ø Creates the event handler that specifies to which mouse event you want the action to respond § multiple events can be selected OBJ 7 -12 Copyright 2003, Paradigm Publishing Inc.

Play, Stop, and Stop. All. Sounds Ø Play § uses no parameters § instructs

Play, Stop, and Stop. All. Sounds Ø Play § uses no parameters § instructs Flash to begin playing the movie at the point in the Timeline at which the action is executed Ø Stop § uses no parameters § instructs Flash to stop playing the movie Ø Stop. All. Sounds OBJ 7 -13 § stops all sounds that are currently playing § stream sounds will resume playing when the playhead reaches the frame in which it has been associated Copyright 2003, Paradigm Publishing Inc.

Assigning Labels to a Keyframe -to reference the destination by name instead of number

Assigning Labels to a Keyframe -to reference the destination by name instead of number -if frames are added, moved, or removed, no change is required to the Action. Script. key a name frame label displays next to a red flag OBJ 7 -14 Copyright 2003, Paradigm Publishing Inc.

Assigning Comments to a Keyframe -helps you to remember what is happening in segments

Assigning Comments to a Keyframe -helps you to remember what is happening in segments of the Timeline -editing is made easier precede comment text with two forward slashes OBJ 7 -15 usually entered two green slashes in a display in front separate layer of comment text Comments can also be added in Action. Script code. Copyright 2003, Paradigm Publishing Inc.

Creating a Preloader Animation Ø A simple animation at the beginning of a movie

Creating a Preloader Animation Ø A simple animation at the beginning of a movie that loops until the download is completed Ø Key concepts: § small animation at the beginning that contains simple text such as a Loading message § Action. Script is added at the end to create a loop § Action. Script is added at the first frame that performs a conditional test OBJ 7 -16 Copyright 2003, Paradigm Publishing Inc.

Performing a Conditional Test Ø Use the if action Ø Can have two possible

Performing a Conditional Test Ø Use the if action Ø Can have two possible outcomes § true § false if (conditional test) { action to be performed if test is true } OBJ 7 -17 Ø A false action is not required since Flash will simply skip the actions in the curly braces and move to the next line of code if the conditional test proves false Copyright 2003, Paradigm Publishing Inc.

Adding an Else Statement Ø Use to specify a false action Ø Add immediately

Adding an Else Statement Ø Use to specify a false action Ø Add immediately after the if action if (frames loaded = all frames) { goto. And. Play(main movie); } else { goto. And. Play(preloader animation); } OBJ 7 -18 Copyright 2003, Paradigm Publishing Inc.

Nesting If Statements Ø To perform a test that has more than two possible

Nesting If Statements Ø To perform a test that has more than two possible outcomes Ø Add an else if action after the initial if block if (frames loaded = all frames) { goto. And. Play(main movie); } else if (frames loaded > 10) { goto. And. Play(preloader animation B); } else { goto. And. Play(preloader animation A); } OBJ 7 -19 Copyright 2003, Paradigm Publishing Inc.

Testing for Status of Frames Loaded Ø Each movie Timeline has a set of

Testing for Status of Frames Loaded Ø Each movie Timeline has a set of properties identified with an underscore character in front of the property name that can be checked or modified § _framesloaded property returns the number of frames that have been downloaded § _totalframes property returns a value representing the total number of frames within a movie OBJ 7 -20 Copyright 2003, Paradigm Publishing Inc.

Testing for Status of Frames Loaded…/2 Ø Properties are identified with an underscore character

Testing for Status of Frames Loaded…/2 Ø Properties are identified with an underscore character at the beginning (_framesloaded == _totalframes) Ø Two equals symbols (equality operator) tells Flash to check if the value for the property on the left equals the value for the property on the right OBJ 7 -21 Copyright 2003, Paradigm Publishing Inc.

Adding Actions for a Preloader Animation insert a new layer cut, paste, and clear

Adding Actions for a Preloader Animation insert a new layer cut, paste, and clear frames as necessary use the drawing tools to create the preloader in frame 1 insert a keyframe and delete the drawn preloader OBJ 7 -22 Copyright 2003, Paradigm Publishing Inc.

Adding Actions for a Preloader Animation…/2 insert a new layer insert a keyframe double-click

Adding Actions for a Preloader Animation…/2 insert a new layer insert a keyframe double-click goto This action will create a loop in which frames 1 -11 will continually replay. OBJ 7 -23 Copyright 2003, Paradigm Publishing Inc.

Adding Actions for a Preloader Animation…/3 click if in frame 1 of the Actions

Adding Actions for a Preloader Animation…/3 click if in frame 1 of the Actions layer double-click properties to add to text box -key spaces and equals signs double-click goto key frame number OBJ 7 -24 This action will move the playhead to frame 12 when all of the frames have been downloaded. Copyright 2003, Paradigm Publishing Inc.

Adding Actions for a Preloader Animation…/4 click frame 12 in the Actions layer double-click

Adding Actions for a Preloader Animation…/4 click frame 12 in the Actions layer double-click This action causes Flash to stop playing the main movie Timeline. OBJ 7 -25 Copyright 2003, Paradigm Publishing Inc.

Using Buttons to Toggle the Playing of a Soundtrack On and Off Ø A

Using Buttons to Toggle the Playing of a Soundtrack On and Off Ø A streamed soundtrack in a movie clip symbol can be the target action for start and stop sound buttons § provides the user with the ability to turn sound on or off during the movie playback Ø Requires Action. Script using the with statement OBJ 7 -26 Copyright 2003, Paradigm Publishing Inc.

With Statement targets a named instance of a movie clip stop playing the sound

With Statement targets a named instance of a movie clip stop playing the sound upon pressing and releasing the mouse over the button OBJ 7 -27 Copyright 2003, Paradigm Publishing Inc. start playing the sound upon pressing and releasing the mouse over the button

Using the get. URL Action to Open a Web Page During a Movie Ø

Using the get. URL Action to Open a Web Page During a Movie Ø The URL parameter can be an absolute or relative address for a Web page or document Ø Window parameters: § _self: opens within the current window replacing the movie from which it originated § _blank: opens in a new browser window § _parent: opens in the browser in the parent of the current frame § _top: opens in the top-level frame of the current browser window OBJ 7 -28 Copyright 2003, Paradigm Publishing Inc.

Using the get. URL Action to Open a Web Page During a Movie…/2 -publish

Using the get. URL Action to Open a Web Page During a Movie…/2 -publish the movie as HTML and as a projector file File, Publish Settings or Ctrl + Shift + F 12 click OBJ 7 -29 Copyright 2003, Paradigm Publishing Inc.

Using the fscommand to Control the Player Window Ø Used to control the environment

Using the fscommand to Control the Player Window Ø Used to control the environment in the window hosting the movie Ø Commands for standalone player include fullscreen, allowscale, showmenu, trapallkeys, exec, and quit OBJ 7 -30 Copyright 2003, Paradigm Publishing Inc.

Creating a Template -saves time and ensures consistency -include standard elements such as a

Creating a Template -saves time and ensures consistency -include standard elements such as a company logo, colors, and publishing options File, Save As Template preview appears key a name choose or add a category key a brief description of the standardized elements OBJ 7 -31 click Save Copyright 2003, Paradigm Publishing Inc.

Using a Template File, New From Template click category name click template name description

Using a Template File, New From Template click category name click template name description is displayed click Create OBJ 7 -32 Copyright 2003, Paradigm Publishing Inc.

Using the Movie Explorer Panel -a tool with which you can locate or view

Using the Movie Explorer Panel -a tool with which you can locate or view objects in a movie in a hierarchical display Window, Movie Explorer or Alt + F 3 Show Text Show Buttons, Movie Clips and Graphics Show Action Scripts Show Video, Sounds and Bitmaps Show Frames and Layers Expand to view Action. Script statements OBJ 7 -33 Copyright 2003, Paradigm Publishing Inc. Customize which Items to Show

Finding Information About Flash on the Web Ø Go to the Source § Macromedia

Finding Information About Flash on the Web Ø Go to the Source § Macromedia maintains tech notes and tutorials on the Flash support center that provide articles on Flash features including step-by-step instructions § www. macromedia. com/support/flash Ø Flashkit. com Flash Developer Resource Site § a Web site for developers that includes several resources including forums and free downloads to assist with building Flash movies § www. flashkit. com Ø Flash Magazine § a Web site maintained by volunteer Flash developers from around the world with articles and tutorials on using Flash § www. flashmagazine. com OBJ 7 -34 Copyright 2003, Paradigm Publishing Inc.

Commands Review How do you display the Actions panel? Window, Actions or F 9

Commands Review How do you display the Actions panel? Window, Actions or F 9 OBJ 7 -35 Copyright 2003, Paradigm Publishing Inc.

Commands Review How do you display the Movie Explorer panel? Window, Movie Explorer or

Commands Review How do you display the Movie Explorer panel? Window, Movie Explorer or Alt + F 3 OBJ 7 -36 Copyright 2003, Paradigm Publishing Inc.

Commands Review How do you create a new document based on a template? File,

Commands Review How do you create a new document based on a template? File, New From Template OBJ 7 -37 Copyright 2003, Paradigm Publishing Inc.

Commands Review How do you display the Publish Settings dialog box? File, Publish Settings

Commands Review How do you display the Publish Settings dialog box? File, Publish Settings or Ctrl + Shift + F 12 OBJ 7 -38 Copyright 2003, Paradigm Publishing Inc.

Commands Review How do you save a document as a template? File, Save As

Commands Review How do you save a document as a template? File, Save As Template OBJ 7 -39 Copyright 2003, Paradigm Publishing Inc.

OBJ 7 -40 Copyright 2003, Paradigm Publishing Inc.

OBJ 7 -40 Copyright 2003, Paradigm Publishing Inc.