Understanding the ActionScript Language > Using actions

 

Using actions

Actions are ActionScript statements, or commands. Multiple actions assigned to the same frame or object create a script. Actions can act independently of each other, as in the following statements:

mc1.swapDepths(mc2);
gotoAndPlay(15);

You can also nest actions by using one action inside another; this allows actions to affect each other. In the following example, the if action tells the gotoAndPlay action when to execute:

if (i >= 25) {
	gotoAndPlay(10);
}

Actions can move the playhead in the Timeline (gotoAndPlay), control the flow of a script by creating loops (do while) or conditional logic (if), or create new functions and variables (function, setVariable). The following table lists all ActionScript actions:

break

#endinitclip

loadMovie

printAsBitmap

switch

call

evaluate

loadMovieNum

printAsBitmapNum

tellTarget

call function

for

loadVariables

printNum

toggleHighQuality

case

for..in

loadVariablesNum

removeMovieClip

trace

clearInterval

fsCommand

method

return

unloadMovie

comment

function

nextFrame

set variable

unloadMovieNum

continue

getURL

nextScene

setInterval

updateAfterEvent

default

gotoAndPlay

on

setProperty

var

delete

gotoAndStop

onClipEvent

startDrag

with

do while

if

play

stop

while

duplicateMovieClip

ifFrameLoaded

prevFrame

stopAllSounds

 

else

include

prevScene

stopDrag

 

else if

#initclip

print

swapDepths

 


For syntax and usage examples of each action, see individual entries in the online ActionScript Dictionary in the Help menu.

Note: In this manual, the ActionScript term action is synonymous with the JavaScript term statement.