With ActionScript®, you can control symbols at runtime. Using ActionScript allows you to create interaction and other capabilities in your FLA files that are not possible with the Timeline alone.

With ActionScript®, you can control symbols at runtime. Using ActionScript allows you to create interaction and other capabilities in your FLA files that are not possible with the Timeline alone.

See the discussion of symbols and ActionScript in web Help to learn about controlling symbols at runtime.

Controlling instances and symbols with ActionScript

To control movie clip and button instances, use ActionScript®. The movie clip or button instance must have a unique instance name to be used with ActionScript. You can write the ActionScript yourself or use the pre-defined behaviors included with Animate.

Controlling instances with behaviors

In FLA files where the ActionScript Publish setting is set to ActionScript 2.0, you can use behaviors to control movie clip and graphic instances in a document without writing ActionScript. Behaviors are prewritten ActionScript scripts that let you add ActionScript coding to your document without having to create the ActionScript code yourself. Behaviors are not available for ActionScript 3.0.

You can use behaviors with an instance to arrange it in the stacking order on a frame, as well as to load or unload, play, stop, duplicate, or drag a movie clip, or to link to a URL.

In addition, you can use behaviors to load an external graphic or an animated mask into a movie clip.

Animate includes the behaviors in the following table.

Behavior

Purpose

Select or input

Load Graphic

Loads an external JPEG file into a movie clip or screen.

Path and filename of JPEG file.

Instance name of movie clip or screen receiving the graphic.

Load External Movieclip

Loads an external SWF file into a target movie clip or screen.

URL of external SWF file.

Instance name of movie clip or screen receiving the SWF file.

Duplicate Movieclip

Duplicates a movie clip or screen.

Instance name of movie clip to duplicate.

X-offset and Y-offset of pixels from original to copy.

Goto And Play at frame or label

Plays a movie clip from a particular frame.

Instance name of target clip to play.

Frame number or label to play.

Goto And Stop at frame or label

Stops a movie clip, optionally moving the playhead to a particular frame.

Instance name of target clip to stop.

Frame number or label to stop.

Bring To Front

Brings target movie clip or screen to the top of the stacking order.

Instance name of movie clip or screen.

Bring Forward

Brings target movie clip or screen one position higher in the stacking order.

Instance name of movie clip or screen.

Send To Back

Sends the target movie clip to the bottom of the stacking order.

Instance name of movie clip or screen.

Send Backward

Sends the target movie clip or screen one position lower in the stacking order.

Instance name of movie clip or screen.

Start Dragging Movieclip

Starts dragging a movie clip.

Instance name of movie clip or screen.

Stop Dragging Movieclip

Stops the current drag.

Unload Movieclip

Removes a movie clip that was loaded by means of loadMovie() from Flash Player.

Instance name of movie clip.

Add and configure a behavior

Be sure you are working in a FLA file whose ActionScript Publish setting is ActionScript 2.0 or earlier.

  1. Select the object, such as a button, to trigger the behavior.
  2. In the Behaviors panel (Window > Behaviors), click the Add (+) button and select the desired behavior from the Movieclip submenu.
  3. Select the movie clip to control with the behavior.
  4. Select a relative or absolute path.
  5. If required, select or input settings for the behavior parameters and click OK. Default settings for the behavior appear in the Behaviors panel.
  6. Under Event, click On Release (the default event) and select a mouse event from the menu. To use the On Release event, leave the option unchanged.

Create custom behaviors

To write custom behaviors, create an XML file that contains the ActionScript 3.0 code to perform the desired behavior, and save the file in the Behaviors folder of your local computer. 

Before you create your own behaviors, examine the Behavior XML files to develop an understanding of the syntax of the XML files, as well as the ActionScript code used to create behaviors. If you are new to writing behaviors, familiarize yourself with the XML tags used to create user interface elements (such as dialog boxes), and with ActionScript, the coding language used to create behaviors. To learn about the XML used to create interface elements, see Extending Animate. To learn about ActionScript, see Learning ActionScript 3.0.

You can also download behaviors that other Animate users have created from the Adobe Flash Exchange website. You can visit the Adobe Exchange at: www.adobe.com/go/flash_exchange.

 

  1. Using an XML editor, open an existing behavior’s XML file, and rename the file appropriately for the behavior you intend to create.
  2. Enter a new value for the category attribute of the behavior_devinition tag in the XML file.

    The following XML code creates a category named myCategory in the Animate Behaviors panel under which the behavior will be listed.

    <behavior_definition dialogID="Trigger-dialog" category="myCategory" 
    authoringEdition="pro" name="behaviorName">
  3. Enter a new value for the name attribute of the behavior_definition tag. This will be the name of the behavior as it will appear in the Animate authoring environment.

  4. (Optional) If your custom behavior requires a dialog box, enter parameters using the <properties> and <dialog> tags.

    To learn about the tags and parameters used to create your own custom dialog boxes, see Extending Animate.

  5. In the <actionscript> tag, insert the ActionScript code to create the behavior.

    If you are new to ActionScript, see Learning ActionScript 3.0.

    For example (from the Movieclip_loadMovie.xml behavior file) (ActionScript 2.0):

    <actionscript> 
      <![CDATA[     //load Movie Behavior 
        if($target$ == Number($target$)){ 
            loadMovieNum($clip$,$target$); 
        } else { 
            $target$.loadMovie($clip$); 
        } 
        //End Behavior 
      ]]> 
    </actionscript>
  6. Save the file and test the behavior.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy