Upload
kalea
View
54
Download
0
Embed Size (px)
DESCRIPTION
Macromedia Flash Design & Application. Chapter 7. Using ActionScript and Creating Templates. Performance Objectives. Define the terms object-oriented programming, object, method, action, event, and parameters. List general guidelines for creating ActionScript in movies. - PowerPoint PPT Presentation
Citation preview
7-7-11
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
Using ActionScript and Creating Templates
Macromedia FlashMacromedia FlashDesign & ApplicationDesign & Application
7-7-22
OBJOBJ
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
7-7-33
OBJOBJ
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
7-7-44
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
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
7-7-55
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
Object-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
7-7-66
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
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
7-7-77
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
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
7-7-88
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
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.
7-7-99
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
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
7-7-1010
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
Controlling Movie PlaybackControlling Movie Playback
7-7-1111
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
GotoGoto 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
7-7-1212
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
OnOn
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
7-7-1313
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
Play, 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
7-7-1414
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
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.
key a name
frame label displaysnext to a red flag
7-7-1515
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
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
precede commenttext with two
forward slashes usually enteredin a
separate layer
two green slashesdisplay in front
of comment text
Comments can also be added in ActionScript code.
7-7-1616
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
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
7-7-1717
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
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
}
7-7-1818
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
Adding 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);
}
7-7-1919
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
Nesting 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);
}
7-7-2020
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
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
7-7-2121
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
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)
7-7-2222
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
Adding 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
7-7-2323
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
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 layerinsert a keyframe
double-click goto
7-7-2424
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
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
7-7-2525
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
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
7-7-2626
OBJOBJ
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 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
7-7-2727
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
With 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
7-7-2828
OBJOBJ
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
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
7-7-2929
OBJOBJ
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
-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
7-7-3030
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
Using 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
7-7-3131
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
Creating 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 TTemplateemplatekey a namechoose or add
a categorykey a brief description
of the standardizedelements
preview appears
click Save
7-7-3232
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
Using a TemplateUsing a Template
FFile, Nile, Neew From Templatew From Templateclick category name
click template name
description isdisplayed
click Create
7-7-3333
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
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 ScriptsShow Video, Sounds
and BitmapsShow Frames and Layers
Customize whichItems to Show
Expand to viewActionScriptstatements
7-7-3434
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
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
7-7-3535
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
Commands ReviewCommands Review
How do you display the Actions panel?
WWindow, indow, AActions or F9ctions or F9
7-7-3636
OBJOBJ
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
7-7-3737
OBJOBJ
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
7-7-3838
OBJOBJ
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
7-7-3939
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.
Commands ReviewCommands Review
How do you save a document as a template?
FFile, Save As ile, Save As TTemplateemplate
7-7-4040
OBJOBJ
Copyright 2003, Paradigm Publishing Inc.