Adobe

Working with ActionScript


 
By clicking Submit, you accept the Adobe Terms of Use.
 

  • Getting started with ActionScript
  • The Actions panel
  • Script window overview
  • Tools in the Actions panel and Script window
  • Access context-sensitive Help from the Actions panel
  • Set ActionScript preferences
    To the top

    Getting started with ActionScript

    The ActionScript® scripting language lets you add complex interactivity, playback control, and data display to your application. You can add ActionScript in the authoring environment by using the Actions panel, Script window, or an external editor.

    ActionScript follows its own rules of syntax, reserved keywords, and lets you use variables to store and retrieve information. ActionScript includes a large library of built‑in classes that let you create objects to perform many useful tasks. For more information on ActionScript, see the following Help titles:

    • Learning ActionScript 3.0 at www.adobe.com/go/learn_flcs5_learnas3_en

    • Learning ActionScript 2.0 in Adobe Flash at www.adobe.com/go/learn_cs5_learningas2_en

    You don’t need to understand every ActionScript element to begin scripting; if you have a clear goal, you can start building scripts with simple actions.

    ActionScript and JavaScript are both rooted in the ECMA-262 standard, the international standard for the ECMAScript scripting language. For this reason, developers who are familiar with JavaScript should find ActionScript immediately familiar. For more information about ECMAScript, go to ecma-international.org.

    Adobe recommends...


    Building an application

    by Todd Perkins



    This video shows you how to use ActionScript to build a simple, interactive application. Use keyboard shortcuts to view ActionScript. Add event listeners and stop actions. (6:07)

    Contribute your expertise to
    Adobe Community Help


    Adobe recommends

    Have a tutorial you would like to share?

    Indroduction to ActionScript 3.0

    Slekx.com
    Discover the fundamentals of ActionScript 3.0 by building your own Flash applications. In just nine short lessons, you'll learn how to use AS3 to interact with internet users worldwide.

    Which version of ActionScript should you use?

    Flash includes more than one version of ActionScript to meet the needs of different kinds of developers and playback hardware. ActionScript 3.0 and 2.0 are not compatible with each other.

    • ActionScript 3.0 executes extremely fast. This version requires somewhat more familiarity with object-oriented programming concepts than the other ActionScript versions. ActionScript 3.0 is fully compliant with the ECMAScript specification, offers better XML processing, an improved event model, and an improved architecture for working with onscreen elements. FLA files that use ActionScript 3.0 cannot include earlier versions of ActionScript.

    • ActionScript 2.0 is simpler to learn than ActionScript 3.0. Although Flash Player runs compiled ActionScript 2.0 code slower than compiled ActionScript 3.0 code, ActionScript 2.0 is still useful for many kinds of projects that are not computationally intensive; for example, more design-oriented content. ActionScript 2.0 is also based on the ECMAScript spec, but is not fully compliant.

    • ActionScript 1.0 is the simplest form of ActionScript, and is still used by some versions of the Flash Lite Player. ActionScript 1.0 and 2.0 can coexist in the same FLA file.

    • Flash Lite 2.x ActionScript is a subset of ActionScript 2.0 that is supported by Flash Lite 2.x running on mobile phones and devices.

    • Flash Lite 1.x ActionScript is a subset of ActionScript 1.0 that is supported by Flash Lite 1.x running on mobile phones and devices.

    Using the ActionScript documentation

    Because there are multiple versions of ActionScript (2.0 and 3.0), and multiple ways of incorporating it into your FLA files, there are several different ways to learn ActionScript.

    This chapter describes the graphical user interface for working with ActionScript. This interface includes the Actions panel, Script window, Script Assist mode, Behaviors panel, Output panel, and Compiler Errors panel. These topics apply to all versions of ActionScript.

    Other ActionScript documentation from Adobe will help you learn about the individual versions of ActionScript; see Programming ActionScript 3.0, Learning ActionScript 2.0 in Adobe Flash, Developing Flash Lite 1.x Applications or Developing Flash Lite 2.x Applications. For information about the ActionScript vocabulary, see the ActionScript Language Reference for the version you are working with.

    Ways of working with ActionScript

    There are several ways to work with ActionScript.
    • Script Assist mode lets you add ActionScript to your FLA file without writing the code yourself. You select actions, and the software presents you with a user-interface for entering the parameters required for each one. You must know a little about what functions to use to accomplish specific tasks, but you don’t have to learn syntax. Many designers and non-programmers use this mode.

    • Behaviors also let you add code to your file without writing it yourself. Behaviors are prewritten scripts for common tasks. You can add a behavior and then easily configure it in the Behaviors panel. Behaviors are available only for ActionScript 2.0 and earlier.

    • Writing your own ActionScript gives you the greatest flexibility and control over your document, but it requires you to become familiar with the ActionScript language and conventions.

    • Components are prebuilt movie clips that help you implement complex functionality. A component can be a simple user interface control, such as a check box, or it can be a complicated control, such as a scroll pane. You can customize a component’s functionality and appearance, and you can download components created by other developers. Most components require you to write some ActionScript code of your own to trigger or control a component. For more information, see Using ActionScript 3.0 Components.

    Writing ActionScript

    When you write ActionScript code in the authoring environment, you use the Actions panel or Script window. The Actions panel and Script window contain a full-featured code editor that includes code hinting and coloring, code formatting, syntax highlighting, syntax checking, debugging, line numbers, word wrapping, and support for Unicode.

    • Use the Actions panel to write scripts that are part of your Flash document (that is, scripts that are embedded in the FLA file). The Actions panel provides features such as the Actions toolbox, which gives you quick access to the core ActionScript language elements, and Script Assist mode, in which you are prompted for the elements needed to create scripts.

    • Use the Script window if you want to write external scripts—that is, scripts or classes that are stored in external files. (You can also use a text editor to create an external AS file.) The Script window includes code-assistance features such as code hinting and coloring, syntax checking, and auto-formatting.

    Additional recommended community content

    The following additional videos provide detailed demonstrations of using ActionScript 3.0, the Flash Professional workflow, and using components. Some videos show Flash Professional CS3 or CS4, but still apply to Flash Professional CS5 and CS5.5. Some videos may also show Adobe® Flex®, but ActionScript® 3.0 is the same language in both Flash Professional and Flex® and Flash Builder.

    • ActionScript 3.0 (3:00)

    • Flash Downunder – ActionScript 3.0 101 (31:51)

    • Flash in a Flash - Episode 5: Basic interactivity and ActionScript 3.0 (44:50)

    • Layers TV – Episode 20: Buttons in Flash (14:23)

    • Getting started with ActionScript 3.0 (CS3) (3:25)

    • Optimizing animations and FLA files (7:24) (CS3)

    • Creating a Document class using ActionScript 3.0 (CS3) (2:38)

    • Creating an effective workflow between design and development (CS3) (3:41)

    • Using components (CS3) (1:47)

    • Pixel Bender: Custom Filters (9:20)

    • E4X – EcmaScript for XML (56:04)

    • Double feature on Alchemy (9:08) (Convert C/C++ code to ActionScript 3.0)

    • Flash Downunder – Pixel Bender filters (15:07)

    • Using the Bitmap Data API in Flash (7:30)

    • Advanced ActionScript APIs (67:40)

    • JavaScript to Flash and Back (18:18)

    • An introduction to AlivePDF (7:14) (Create PDFs from ActionScript 3.0)

    • An introduction to WiiFlash (7:26) (Use the Wii controller with AIR, Flash and Flex)

    • Lynda.com Training for Developers – ActionScript 3.0 – Ch.3 Create an image gallery (4:51)

    • Lynda.com Training for Developers – ActionScript 3.0 – Ch.4 Responding to mouse events (4:07)

    • YouTube.com list of ActionScript channels

    The following articles and tutorials provide additional detailed information about working with ActionScript:

    • Introduction to ActionScript 3.0 (Slekx.com)

    • Tips for learning ActionScript 3 (Adobe.com)

    • Introduction to event handling in ActionScript 3 (Adobe.com)

    • ActionScript 3.0 Migration Resources for Flash (Adobe.com)

    • Migrating to ActionScript 3: Key concepts and changes (Adobe.com)

    • Top five misperceptions about ActionScript 3 (Adobe.com)

    • ActionScript 3 migration cookbook (Adobe.com)

    • ActionScript 3 migration table (Adobe.com)

    • Flash and ActionScript components learning guide (Adobe.com)

    • Flash ActionScript 2.0 Learning Guide (Adobe.com)

    To the top

    The Actions panel

      Looking for the Language Reference?

      To find reference documentation for a specific ActionScript language element, do one of the following:

      • Open the ActionScript 3.0 Language Reference, and search for the language element.

      • Open the ActionScript 2.0 Language Reference, and search for the language element.

      • Type the language element in the Actions panel, select it, then press F1. (You must press F1 immediately, or this topic opens instead.)

      Note: To open the Help in a web browser instead of the Community Help application, see this article: http://kb2.adobe.com/community/publishing/916/cpsid_91609.html.

      Learning ActionScript

      Adobe recommends


      ActionScript 3 101

      by Paul Burnett



      Paul walks you through you a brief introduction to AS3. This episode is very simple and helps you get started using event listeners in Flash so you can begin adding interaction to your Flash projects.

      Contribute your expertise to
      Adobe Community Help


      This article is about using the functionality of the Actions panel in Flash Professional, not about writing ActionScript code.

      To learn about writing ActionScript, use these resources:

      • Learning ActionScript 3.0

      • ActionScript 3.0 Language and Components Reference

      • Introduction to ActionScript 3.0 (Slekx.com)

      • Learning ActionScript 2.0 in Adobe Flash

      • ActionScript 2.0 Language Reference

      Note: ActionScript 3.0 and 2.0 are not compatible with each other. You must choose only one version to use in each FLA file you create.

      Overview of the Actions panel

      To create scripts embedded in a FLA file, enter ActionScript directly into the Actions panel (Window > Actions or press F9).

      A.
      Script pane

      B.
      Panel menu

      C.
      Actions toolbox

      D.
      Script navigator

      The Actions panel consists of three panes:

      Script pane
      Lets you type ActionScript code, which is associated with the currently selected frame (or, for ActionScript 2 only, the currently selected object).

      To keep a particular script displayed in the Script pane, pin the script by clicking the Pin button at the bottom of the pane.

      Actions toolbox
      Groups ActionScript elements by category and provides an alphabetical index. To insert an ActionScript element into the Script pane, double-click it or drag it directly into place in your code in the Script pane..

      Script navigator
      Lists the scripts in your Flash document, and lets you move quickly between them. Click an item in the Script navigator to view the script in the Script pane.

      To pin a script in the Actions panel, double-click it in the Script navigator. Pinned scripts remain in the Script pane even when a different frame or object is selected in the Timeline or on the Stage.

      To hide the Actions toolbox and Script navigator, click the Show/Hide Toolbox button  at the top of the Actions panel. When the Actions toolbox is hidden, you can still use the Add (+) button to access its items.

      Print ActionScript

      1. From the Actions panel pop‑up menu, select Print.
      2. Select Options and click Print.

        Because the printed copy won’t include information about file it came from, you should include information such as the name of the FLA file in a comment in the script.

      To the top

      Script window overview

      The Script window lets you create external script files that you import into your application. These scripts can be ActionScript, Flash Communication, or Flash JavaScript files. The Add (+) menu lists the language elements available for the type of script you create.

      Script window

      If you have more than one external file open, filenames are displayed on tabs across the top of the Script window.

      In the Script window, you can use the following features: the Add (+) menu (which is like the Actions toolbox), find and replace, syntax checking, syntax coloring, auto format, code hinting, code commenting, code collapse, debug options (ActionScript files only), and word wrap. The Script window also lets you display line numbers and hidden characters.

      The Script window does not include code-assistance features such as the Script navigator, Script Assist mode, and behaviors. These features are useful only in the context of creating a FLA file, not an external script file.

      Create an external file in the Script window

      1. Select File > New.
      2. Select the type of external file you want to create (ActionScript file, ActionScript Communication file, or Flash JavaScript file).

      Edit an existing file in the Script window

      • To open an existing script, select File > Open, and then open an existing AS file.

      • To edit a script that is already open, click the document tab that shows the script’s name.

      To the top

      Tools in the Actions panel and Script window

      The Actions panel and Script window toolbars let you access the code-assistance features that help simplify and streamline coding in ActionScript. The tools are different depending on whether you are using the Actions panel or the Script window.
      Add A New Item To The Script 
      Displays the language elements that are also in the Actions toolbox. Select an item to add it to the script.

      Find 
      Finds and replaces text in your script.

      Insert Target Path 
      (Actions panel only) Helps you set an absolute or relative target path for an action in the script.

      Check Syntax 
      Checks for syntax errors in the current script. Syntax errors are listed in the Output panel.

      Auto Format 
      Formats your script for proper coding syntax and improved readability. Set autoformatting preferences in the Preferences dialog box, which is available from the Edit menu or from the Actions Panel menu.

      Show Code Hint 
      If you’ve turned off automatic code hinting, use Show Code Hint to display a code hint for the line of code you’re working on.

      Debug Options 
      (Actions panel only) Sets and removes breakpoints so that you can proceed line by line through your script when debugging. You can use debug options only for ActionScript files, not ActionScript Communication or Flash JavaScript files.

      Collapse Between Braces 
      Collapses code that appears between the curly braces or parentheses that currently contain the insertion point.

      Collapse Selection 
      Collapses the currently selected code block.

      Expand All 
      Expands all collapsed code in the current script.

      Apply Block Comment 
      Adds comment markers to the beginning and end of the selected code block.

      Apply Line Comment 
      Adds a single-line comment marker at the insertion point, or at the beginning of each line of code in a multiline selection.

      Remove Comment 
      Removes comment markers from the current line or all lines of the current selection.

      Show/Hide Toolbox 
      Displays or hides the Actions Toolbox.

      Script Assist 
      (Actions panel only) In Script Assist mode, you are presented with a user-interface for entering the elements needed to create scripts.

      Help 
      Displays reference information for the ActionScript element that is selected in the Script pane. For example, if you click an import statement and then click Help, the reference information for import appears in the Help panel.

      Panel menu 
      (Actions panel only) Contains the commands and preferences that apply to the Actions panel. For example, you can set line numbers and word wrapping, access ActionScript preferences, and import or export scripts.

      To the top

      Access context-sensitive Help from the Actions panel

      1. To select an item for reference, do any of the following:
        • Select an ActionScript term in the Actions panel toolbox pane (on the left side of the Actions panel).

        • Select an ActionScript term in the Actions panel in the Script pane.

        • Place the insertion point before an ActionScript term in the Actions panel in the Script pane.

      2. To open the Help panel reference page for the selected item, do one of the following:
        • Press F1.

        • Right-click the item and select View Help.

        • Click Help  above the Script pane.

      To the top

      Set ActionScript preferences

      Whether you edit code in the Actions panel or the Script window, you can set and modify a single set of preferences.

      1. Select Edit > Preferences (Windows) or Flash > Preferences (Macintosh), and then click ActionScript in the Category list.
      2. Set any of these preferences:
        Automatic Indentation
        When automatic indentation is turned on, the text you type after an opening parenthesis “(“ or opening curly brace “{“ is automatically indented according to the Tab Size setting.

        Tab Size
        Specifies the number of characters a new line is indented.

        Code Hints
        Enables code hinting in the Script pane.

        Delay
        Specifies the delay (in seconds) before code hints are displayed.

        Font
        Specifies the font used for your script.

        Use Dynamic Font Mapping
        Checks to ensure that the selected font family can render each character. If not, Flash substitutes a font family that contains the necessary characters.

        Open/Import
        Specifies the character encoding used when you open or import ActionScript files.

        Save/Export
        Specifies the character encoding used when you save or export ActionScript files.

        Reload Modified Files
        Specifies what happens when a script file is modified, moved, or deleted. Select Always, Never, or Prompt.
        Always
        No warning is displayed, and the file is automatically reloaded.

        Never
        No warning is displayed, and the file remains in the current state.

        Prompt
        (Default) A warning is displayed, and you can choose whether to reload the file.

        When you build applications with external scripts, this preference helps you avoid overwriting a script that a team member has modified since you opened the application, or avoid publishing the application with older versions of scripts. The warnings let you automatically close a script and reopen the newer, modified version.

        Syntax Colors
        Specifies code coloring in your scripts.

        Language
        These buttons open the ActionScript Settings dialog boxes, where you can set a classpath for ActionScript 2.0, or a source path, library path, and external library path for ActionScript 3.0.

      More Help topics

      Symbols and ActionScript

      Timelines and ActionScript

      Sound and ActionScript

      Controlling external video playback with ActionScript

      Multilanguage text and ActionScript

      Creating accessibility with ActionScript

      Best practices - Organizing ActionScript in an application

      Debugging ActionScript 1.0 and 2.0

      Script Assist mode and behaviors

      Pin scripts in the Actions panel

      Writing and managing scripts

      Set the source path for ActionScript 3.0

      Set the classpath for ActionScript 2.0

      Import and export scripts

      Format code

      Use code hints

      Debugging ActionScript 3.0

      Legal Notices   |   Online Privacy Policy