Jump to content

Beginner's Guide to Adobe Flash/Interactivity/ActionScript

From Wikibooks, open books for an open world

ActionScript is an ECMAScript-based programming language used for scripting Adobe Flash movies and applications. Since both ActionScript and JavaScript are based on the same syntax, fluency in one translates easily to the other. However, while JavaScript's DOM is browser window-, document- and form-centric, the ActionScript DOM is movie-centric, which may include animations, audio, text and event handling.

Each action must be in a keyframe.

It's a good design strategy to keep all your actions on a separate layer named "Actions" or something similar.

To make a button that, when clicked, loads a URI, right-click the button's instance, and select "Actions" from the menu. Then, enter this code:

on( release )
{
  getURL( "<URI>", ["<target>"], ["<method>"] )
}

where "target" refers to a window type (e.g. "_blank" for a new window).

One commonly used ActionScript function is gotoAndPlay. It takes the form gotoAndPlay( <frame> ). When run, it will move the player to that frame and resume play. For example, gotoAndPlay( 5 ) will move to frame 5 and resume playing, and gotoAndPlay( "menu" ) will go to the frame named "menu" and resume playing.

A similar function is gotoAndStop( <frame> ), which goes to the frame referenced but does not resume playing.