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

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

Embed Size (px)

Citation preview

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

7-7-11OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Using ActionScript and Creating Templates

Macromedia FlashMacromedia FlashDesign & ApplicationDesign & Application

Page 2: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-22OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

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

List general guidelines for creating ActionScript 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.

Performance ObjectivesPerformance Objectives

Page 3: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-33OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

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 getURL 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

Performance ObjectivesPerformance Objectives

Page 4: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-44OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Understanding ActionScript Understanding ActionScript Concepts and TermsConcepts and Terms

Understanding ActionScript Understanding ActionScript Concepts and TermsConcepts and Terms

ActionScript 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 ActionScript involves: learning the keywords using proper syntax

Page 5: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-55OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Object-Oriented ProgrammingObject-Oriented ProgrammingObject-Oriented ProgrammingObject-Oriented Programming

ActionScript is an object-oriented scripting language similar to JavaScript

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

Page 6: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-66OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Actions, Events, and Actions, Events, and ParametersParameters

Actions, Events, and Actions, Events, and ParametersParameters

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

also called arguments provide the variable information for the

action statement

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

7-7-77OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

General Guidelines for General Guidelines for Writing ActionScriptWriting ActionScript

General Guidelines for General Guidelines for Writing ActionScriptWriting ActionScript

Before starting to write ActionScript 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 ActionScript

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

Page 8: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-88OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

The Actions Panel inThe Actions Panel inNormal ModeNormal Mode

The Actions Panel inThe Actions Panel inNormal ModeNormal Mode

WWindow, indow, AActions or F9ctions or F9

Flash assists you with the programming. The proper syntax for each statement is inserted.

Step 1Double-click

action in toolbox.

Step 2Add parameters ifthe action has any.

Flash buildsthe code for you.

Page 9: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-99OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

The Actions Panel inThe Actions Panel inExpert ModeExpert Mode

The Actions Panel inThe Actions Panel inExpert ModeExpert Mode

The parameters area is replaced with a larger ActionScript area.

Step 1Double-click

action intoolbox.

Step 2Key parameters

usingproper syntax.

Flash does not build thestatement for you. Use

code hints to viewavailable parametersfor the current action.

Check Syntax Show Code Hint

Code Hint

Switching from Expert mode to Normal code causes Flash to check the syntax.

show next code hint

Page 10: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-1010OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Controlling Movie PlaybackControlling Movie PlaybackControlling Movie PlaybackControlling Movie Playback

Page 11: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-1111OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

GotoGotoGotoGoto

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

Page 12: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-1212OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

OnOnOnOn

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

Page 13: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-1313OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Play, Stop, and StopAllSoundsPlay, Stop, and StopAllSoundsPlay, Stop, and StopAllSoundsPlay, Stop, and StopAllSounds

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

StopAllSounds stops all sounds that are currently playing stream sounds will resume playing when

the playhead reaches the frame in which it has been associated

Page 14: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-1414OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Assigning Labels to a Assigning Labels to a KeyframeKeyframe

Assigning Labels to a Assigning Labels to a KeyframeKeyframe

-to reference the destination by name instead of number

-if frames are added, moved, or removed, no change is required to

the ActionScript.

-to reference the destination by name instead of number

-if frames are added, moved, or removed, no change is required to

the ActionScript.

key a name

frame label displaysnext to a red flag

Page 15: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-1515OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Assigning Comments to a Assigning Comments to a KeyframeKeyframe

Assigning Comments to a Assigning Comments to a KeyframeKeyframe

-helps you to remember what is happening in segments of the

Timeline-editing is made easier

-helps you to remember what is happening in segments of the

Timeline-editing is made easier

precede commenttext with two

forward slashesusually entered

in aseparate layer

two green slashesdisplay in front

of comment text

Comments can also be added in ActionScript code.

Page 16: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-1616OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Creating a Preloader Creating a Preloader AnimationAnimation

Creating a Preloader Creating a Preloader AnimationAnimation

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

ActionScript is added at the end to create a loop

ActionScript is added at the first frame that performs a conditional test

Page 17: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-1717OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Performing a Conditional Performing a Conditional TestTest

Performing a Conditional Performing a Conditional TestTest

Use the if action Can have two possible outcomes

true false

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

if (conditional test) {action to be performed if test is true

}

Page 18: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-1818OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Adding an Else StatementAdding an Else StatementAdding an Else StatementAdding an Else Statement

Use to specify a false action Add immediately after the if action

if (frames loaded = all frames) {gotoAndPlay(main movie);

} else {gotoAndPlay(preloader animation);

}

Page 19: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-1919OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Nesting If StatementsNesting If StatementsNesting If StatementsNesting 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) {gotoAndPlay(main movie);

} else if (frames loaded > 10) {gotoAndPlay(preloader animation B);

} else {gotoAndPlay(preloader animation A);

}

Page 20: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-2020OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Testing for Status of Frames Testing for Status of Frames LoadedLoaded

Testing for Status of Frames Testing for Status of Frames LoadedLoaded

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

Page 21: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-2121OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Testing for Status of Frames Testing for Status of Frames Loaded…/2Loaded…/2

Testing for Status of Frames Testing for Status of Frames Loaded…/2Loaded…/2

Properties are identified with an underscore character at the beginning

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

(_framesloaded == _totalframes)

Page 22: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-2222OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Adding Actions for a Adding Actions for a Preloader AnimationPreloader AnimationAdding Actions for a Adding Actions for a Preloader AnimationPreloader Animation

cut, paste, and clearframes as necessary

insert a new layer

use the drawing toolsto create the preloader

in frame 1

insert a keyframeand delete the

drawn preloader

Page 23: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-2323OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Adding Actions for a Adding Actions for a Preloader Animation…/2Preloader Animation…/2

Adding Actions for a Adding Actions for a Preloader Animation…/2Preloader Animation…/2

This action will createa loop in whichframes 1-11 will

continually replay.

insert a new layer

insert a keyframe

double-click goto

Page 24: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-2424OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Adding Actions for a Adding Actions for a Preloader Animation…/3Preloader Animation…/3

Adding Actions for a Adding Actions for a Preloader Animation…/3Preloader Animation…/3

This action will movethe playhead to

frame 12 when allof the frames havebeen downloaded.

click if in frame 1of the Actions layer

double-clickproperties

to add to text box-key spaces and

equals signs

double-clickgoto

key frame number

Page 25: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-2525OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Adding Actions for a Adding Actions for a Preloader Animation…/4Preloader Animation…/4

Adding Actions for a Adding Actions for a Preloader Animation…/4Preloader Animation…/4

This action causesFlash to stop playing

the main movieTimeline.

click frame 12 inthe Actions layer

double-click

Page 26: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-2626OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

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

Using Buttons to Toggle the Using Buttons to Toggle the Playing of a Soundtrack On and OffPlaying 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 ActionScript using the with statement

Page 27: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-2727OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

With StatementWith StatementWith StatementWith Statement

targets a named instance of a movie clip

stop playing the soundupon pressing and releasingthe mouse over the button

start playing the soundupon pressing and releasingthe mouse over the button

Page 28: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-2828OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Using the getURL Action to Open Using the getURL Action to Open a Web Page During a Moviea Web Page During a Movie

Using the getURL Action to Open Using the getURL Action to Open a Web Page During a Moviea 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

Page 29: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-2929OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Using the getURL Action to Open Using the getURL Action to Open a Web Page During a Movie…/2a Web Page During a Movie…/2

Using the getURL Action to Open Using the getURL Action to Open a Web Page During a Movie…/2a Web Page During a Movie…/2

-publish the movie as HTML and as a projector file

-publish the movie as HTML and as a projector file

FFile, Publish Settinile, Publish Settinggs or Ctrl + Shift + F12s or Ctrl + Shift + F12

click

click

Page 30: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-3030OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Using the fscommand to Using the fscommand to Control the Player WindowControl the Player WindowUsing the fscommand to Using the fscommand to

Control the Player WindowControl 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

Page 31: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-3131OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Creating a TemplateCreating a TemplateCreating a TemplateCreating a Template

-saves time and ensures consistency-include standard elements such as a company logo, colors, and publishing

options

FFile, Save As ile, Save As TTemplateemplate

key a name

choose or adda category

key a brief descriptionof the standardized

elements

preview appears

click Save

Page 32: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-3232OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Using a TemplateUsing a TemplateUsing a TemplateUsing a Template

FFile, Nile, Neew From Templatew From Template

click category name

click template name

description isdisplayed

click Create

Page 33: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-3333OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Using the Movie Explorer Using the Movie Explorer PanelPanel

Using the Movie Explorer Using the Movie Explorer PanelPanel

-a tool with which you can locate or view objects in a movie in a hierarchical display

WWindow, indow, MMovie Explorer or Alt + F3ovie Explorer or Alt + F3Show Text

Show Buttons, MovieClips and Graphics

Show Action Scripts

Show Video, Soundsand Bitmaps

Show Frames and Layers

Customize whichItems to Show

Expand to viewActionScriptstatements

Page 34: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-3434OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Finding Information About Finding Information About Flash on the WebFlash on the Web

Finding Information About Finding Information About Flash on the WebFlash 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

Page 35: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-3535OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Commands ReviewCommands Review

How do you display the Actions panel?

WWindow, indow, AActions or F9ctions or F9

Page 36: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-3636OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Commands ReviewCommands Review

How do you display the Movie Explorer panel?

WWindow, indow, MMovie Explorer or Alt + F3ovie Explorer or Alt + F3

Page 37: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-3737OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Commands ReviewCommands Review

How do you create a new document based on a template?

FFile, Nile, Neew From Templatew From Template

Page 38: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-3838OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Commands ReviewCommands Review

How do you display the Publish Settings dialog box?

FFile, Publish Settinile, Publish Settinggs or Ctrl + Shift + F12s or Ctrl + Shift + F12

Page 39: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-3939OBJOBJ

Copyright 2003, Paradigm Publishing Inc.

Commands ReviewCommands Review

How do you save a document as a template?

FFile, Save As ile, Save As TTemplateemplate

Page 40: 7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application

7-7-4040OBJOBJ

Copyright 2003, Paradigm Publishing Inc.