• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Actions

Actions are the heart of ActionScript. Actions are sets of instructions that run when a specific event occurs. The events that trigger actions can range from mouse events and key presses to events that occur when a movie clip is playing (load, unload, data, enterFrame, and so on).

Name Syntax Shortcut Key Description Arguments
break break; Esc+br Instructs Flash to break out of a loop. 
comment // Esc+// Inserts a comment. 
continue continue; Esc+co In a while loop, causes Flash to jump to the top of the loop.

In a do…while loop, causes Flash to jump to the bottom of the loop.

In a for loop, causes Flash to jump to the for loop’s post expression.

In a for...in loop, causes Flash to jump back to the top of the loop.
 
delete delete (reference); Esc+da Deletes the object and returns true if delete was successful. reference The name of the variable to delete.
do while do { statement; } while (condition); Esc+do Executes the statement, and then checks if the condition is true. statement

The statement to be executed.

condition

The condition to check.
duplicate MovieClip duplicateMovieClip(target, newname, depth); Esc+dm Creates an instance of the movie clip; begins to play in frame 1. target

The target path of the movie clip to duplicate.

newname

A unique name for the instance of the movie clip being placed.

depth

The depth level of the movie clip.
else else {statement(s)}; Esc+ el Specifies the actions to complete if the initial if statement returns false. statements The statement to be executed.
elseif elseif (condition) statement(s){} Esc+ei Specifies another condition to check if the initial if statement returns false; if the elseif condition returns true, it executes the statements. statement

The statement to be executed.

condition

The condition to check.
for for(init; condition; next) {statement; Esc+fr A loop that automatically increments. init

The initial loop variable.

condition

The condition to check; returns true or false.

next statement

The increment of the initial loop.
for...in for(variable iterant in object){ statement; } Esc+fi Loops through either the properties of an object or through the elements of an array and executes the statement for each property or element. variable iterant

The variable to be checked for.

object

The object to check for the preceding variable.

statement

What to do if the variable is found.
FSCommand fscommand(command, arguments); Esc+fs Allows the Flash player to communicate with the program that is running it; allows you to call JavaScript commands. command

The string to be passed to the host application.

arguments

The string to be passed to the host application.
function function functionname([argument0, argument1, ...argumentN] ){ statement(s) } function ([argument0, argument1, ...argumentN] ){ statement(s) } Esc+fn A set of statements you define for a particular task. functionname

The unique name of the function.

argument0, argument1, ...argumentN

The variables to pass into the function.

statement(s)

The actions of the function.
getURL getURL(url, window ); Esc+gu Loads a document specified in URL into a specified window. URL

The URL of the document.

window

Specifes the frame or window to load the URL; _blank opens a new window.

variables

Specifies how many variables will be sent.
gotoAnd Play gotoAndPlay(scene, frame); Esc+gp Starts playing a movie at the specified frame. scene

The scene that the frame is located if none is listed; assumes current scene.

frame

The frame number to start playing.
gotoAnd Stop gotoAndStop(scene, frame); Esc+gs Goes to a specified frame in the movie and stops playing. scene

The scene that the frame is located if none is listed; assumes current scene.

frame

The frame number to go to.
if if(condition) { statement; } Esc+if Specifies a statement to execute only if the condition is true. statement

The statement to be executed.

condition

The condition to check.
include #include "filename.as" Esc+il Includes a text file containing ActionScript. filename.as The name of the text file to include.
loadMovie loadMovie Num loadMovie(url, level, variables); loadMovieNum(url, level, variables) Esc+in Esc+lm Loads additional Flash movies (SWF) without closing the current movie. url

The URL of the SWF to load.

level

The level at which to load the movie; set to level 1 or higher to place on top of current movie.

variables

Method of sending data— either GET or POST.
load Variables load Variables Num loadVariables(url ,location, variables); loadVariablesNum(url ,location , variables); Esc+ln Esc+lv Reads data from an external text file into the movie. url

The location of the text file.

variables

Method for retrieving the variables.

location

The level to receive the variables.
nextFrame nextFrame(); Esc+vn Advances to the next frame. 
nextScene nextScene(); Esc+nf Advances to the next scene. 
on on (mouseEvent) { statement } Esc+ns Specifies a statement to execute when the mouseEvent occurs. mouseEvent

Trigger that executes the code.

statement

The statement to be executed.
onClip Event onClipEvent(movieEvent){ statements } Esc+on Specifies a statement to execute when the movieEvent occurs. movieEvent

Trigger that executes the code.

statement

The statement to be executed.
play play(); Esc+pl Plays the timeline. 
prevFrame prevFrame(); Esc+pf Sends the playhead back a frame. 
prevScene prevScene(); Esc+ps Sends the playhead back a scene. 
print object print(target, "bmovie");

print(target, "bmax");

print(target, "bframe");
Esc+pr Prints what is specified. target

The instance name of the movie clip to print.

bmovie

Prints the area given the name of #b.

bmax

Used when the printable frames in your movie vary in size.

bframe

Used when you want each to fill the printed page.
printAs Bitmap printAsBitmap(target, "bmovie");

printAsBitmap(target, "bmax");

printAsBitmap(target, "bframe");
Esc+pbm Prints as a bitmap. target

The instance name of the movie clip to print.

bmovie

Prints the area given the name of #b.

bmax

Used when the printable frames in your movie vary in size.

bframe

Used when you want each object to fill the printed page.
remove MovieClip removeMovieClip(target); Esc+rm Removes the movie clip instance created with the duplicateMovieClip action. target The target path of the movie clip to duplicate.
return return value; Esc+rt Returns the value specified. value The information to be returned.
set variable variable = expression; set(variable, expression); Esc+sv Sets a variable. variable

The name of the container that holds the information.

expression

The value to be contained in the variable.
set Property setProperty(target, property, expression); Esc+sp Modifies the property of a movie clip. target

The target path of the movie clip instance.

property

The property to be set.

expression

The value to which the property is set.
startDrag startDrag(target);

startDrag(target, lockCenter);

startDrag(target ,lockCenter ,left ,top , right, bottom);
Esc+dr  target

Path of the movie clip instance.

lockCenter

A Boolean value; specifies if the movie clip will be locked to the center position of the mouse (true) or not (false), or to the left, top, right, or bottom values to constrain the drag of the movie clip.
stop stop(); Esc+st Allows the movie clip to be draggable. 
stopAll Sounds stopAllSounds(); Esc+ss Stops the movie clip.
stopDrag stopDrag(); Esc+sd Ends the drag action of the movie clip.
trace trace(expression); Esc+tr A statement to evaluate or a variable that will display in the Output window; used for debugging the file. expression A statement to evaluate.
unload Movie unload MovieNum  Esc+um Esc+un Removes a movie clip that was loaded using the loadMovie or attachMovie action.
var varvariable Name1 = expression Esc+vr Used to declare local variables. variableName

The name of the variable.

expression

The value to be contained in the variable.
while while(condition) { statement(s); } Esc+wh Specifies a statement to execute while the condition is true. statement

The statement to be executed.

condition

The condition to check.
with with (object) { statement(s); } Esc+wt Directs the object to perform the tasks defined in the statements. object

An instance of an ActionScript object or movie clip.

statement

The statement to be executed.



PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint