User Guide Cancel

Timelines and ActionScript

  1. Adobe Animate User Guide
  2. Introduction to Animate
    1. What's New in Animate
    2. Visual Glossary
    3. Animate system requirements
    4. Animate keyboard shortcuts
    5. Work with Multiple File Types in Animate
  3. Animation
    1. Animation basics in Animate
    2. How to use frames and keyframes in Animate
    3. Frame-by-frame animation in Animate
    4. How to work with classic tween animation in Animate
    5. Brush Tool
    6. Motion Guide
    7. Motion tween and ActionScript 3.0
    8. About Motion Tween Animation
    9. Motion tween animations
    10. Creating a Motion tween animation
    11. Using property keyframes
    12. Animate position with a tween
    13. How to edit motion tweens using Motion Editor
    14. Editing the motion path of a tween animation
    15. Manipulating motion tweens
    16. Adding custom eases
    17. Creating and applying Motion presets
    18. Setting up animation tween spans
    19. Working with Motion tweens saved as XML files
    20. Motion tweens vs Classic tweens
    21. Shape tweening
    22. Using Bone tool animation in Animate
    23. Work with character rigging in Animate
    24. How to use mask layers in Adobe Animate
    25. How to work with scenes in Animate
  4. Interactivity
    1. How to create buttons with Animate
    2. Convert Animate projects to other document type formats
    3. Create and publish HTML5 Canvas documents in Animate
    4. Add interactivity with code snippets in Animate
    5. Creating custom HTML5 Components
    6. Using Components in HTML5 Canvas
    7. Creating custom Components: Examples
    8. Code Snippets for custom Components
    9. Best practices - Advertising with Animate
    10. Virtual Reality authoring and publishing
  5. Workspace and workflow
    1. Creating and managing Paint brushes
    2. Using Google fonts in HTML5 Canvas documents
    3. Using Creative Cloud Libraries and Adobe Animate
    4. Use the Stage and Tools panel for Animate
    5. Animate workflow and workspace
    6. Using web fonts in HTML5 Canvas documents
    7. Timelines and ActionScript
    8. Working with multiple timelines
    9. Set preferences
    10. Using Animate authoring panels
    11. Create timeline layers with Animate
    12. Export animations for mobile apps and game engines
    13. Moving and copying objects
    14. Templates
    15. Find and Replace in Animate
    16. Undo, redo, and the History panel
    17. Keyboard shortcuts
    18. How to use the timeline in Animate
    19. Creating HTML extensions
    20. Optimization options for Images and Animated GIFs
    21. Export settings for Images and GIFs
    22. Assets Panel in Animate
  6. Multimedia and Video
    1. Transforming and combining graphic objects in Animate
    2. Creating and working with symbol instances in Animate
    3. Image Trace
    4. How to use sound in Adobe Animate
    5. Exporting SVG files
    6. Create video files for use in Animate
    7. How to add a video in Animate
    8. Draw and create objects with Animate
    9. Reshape lines and shapes
    10. Strokes, fills, and gradients with Animate CC
    11. Working with Adobe Premiere Pro and After Effects
    12. Color Panels in Animate CC
    13. Opening Flash CS6 files with Animate
    14. Work with classic text in Animate
    15. Placing artwork into Animate
    16. Imported bitmaps in Animate
    17. 3D graphics
    18. Working with symbols in Animate
    19. Draw lines & shapes with Adobe Animate
    20. Work with the libraries in Animate
    21. Exporting Sounds
    22. Selecting objects in Animate CC
    23. Working with Illustrator AI files in Animate
    24. Applying blend modes
    25. Arranging objects
    26. Automating tasks with the Commands menu
    27. Multilanguage text
    28. Using camera in Animate
    29. Graphic filters
    30. Sound and ActionScript
    31. Drawing preferences
    32. Drawing with the Pen tool
  7. Platforms
    1. Convert Animate projects to other document type formats
    2. Custom Platform Support
    3. Create and publish HTML5 Canvas documents in Animate
    4. Creating and publishing a WebGL document
    5. How to package applications for AIR for iOS
    6. Publishing AIR for Android applications
    7. Publishing for Adobe AIR for desktop
    8. ActionScript publish settings
    9. Best practices - Organizing ActionScript in an application
    10. How to use ActionScript with Animate
    11. Accessibility in the Animate workspace
    12. Writing and managing scripts
    13. Enabling Support for Custom Platforms
    14. Custom Platform Support Overview
    15. Working with Custom Platform Support Plug-in
    16. Debugging ActionScript 3.0
    17. Enabling Support for Custom Platforms
  8. Exporting and Publishing
    1. How to export files from Animate CC
    2. OAM publishing
    3. Exporting SVG files
    4. Export graphics and videos with Animate
    5. Publishing AS3 documents
    6. Export animations for mobile apps and game engines
    7. Exporting Sounds
    8. Best practices - Tips for creating content for mobile devices
    9. Best practices - Video conventions
    10. Best practices - SWF application authoring guidelines
    11. Best practices - Structuring FLA files
    12. Best Practices to optimize FLA files for Animate
    13. ActionScript publish settings
    14. Specify publish settings for Animate
    15. Exporting projector files
    16. Export Images and Animated GIFs
    17. HTML publishing templates
    18. Working with Adobe Premiere Pro and After Effects
    19. Quick share and publish your animations
  9. Troubleshooting
    1. Fixed issues
    2. Known issues

 

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

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

See the discussion of timelines and ActionScript in web Help to learn about controlling the Timeline with ActionScript.

Absolute paths

An absolute path starts with the name of the level into which the document is loaded and continues through the display list until it reaches the target instance. You can also use the alias _root to refer to the topmost Timeline of the current level. For example, an action in the movie clip california that refers to the movie clip oregon could use the absolute path _root.westCoast.oregon.

The first document to open in Flash Player is loaded at level 0. You must assign each additional loaded document a level number. When you use an absolute reference in ActionScript to reference a loaded document, use the form _levelX, where X is the level number into which the document is loaded. For example, the first document that opens in Flash Player is called _level0; a document loaded into level 3 is called _level3.

To communicate between documents on different levels, you must use the level name in the target path. The following example shows how the portland instance would address the atlanta instance located in a movie clip called georgia (georgia is at the same level as oregon):

_level5.georgia.atlanta

You can use the _root alias to refer to the main Timeline of the current level. For the main Timeline, the _root alias stands for _level0 when targeted by a movie clip also on _level0. For a document loaded into _level5, _root is equal to _level5 when targeted by a movie clip also on level 5. For example, if the movie clips southcarolina and florida are both loaded into the same level, an action called from the instance southcarolina could use the following absolute path to target the instance florida:

_root.eastCoast.florida

Relative paths

A relative path depends on the relationship between the controlling Timeline and the target Timeline. Relative paths can address targets only within their own level of Flash Player. For example, you can’t use a relative path in an action on _level0 that targets a Timeline on _level5.

In a relative path, use the keyword this to refer to the current Timeline in the current level; use the _parent alias to indicate the parent Timeline of the current Timeline. You can use the _parent alias repeatedly to go up one level in the movie clip hierarchy within the same level of Flash Player. For example, _parent._parent controls a movie clip up two levels in the hierarchy. The topmost Timeline at any level in Flash Player is the only Timeline with a _parent value that is undefined.

An action in the Timeline of the instance charleston, located one level below southcarolina, could use the following target path to target the instance southcarolina:

_parent

To target the instance eastCoast (one level up) from an action in charleston, you could use the following relative path:

_parent._parent

To target the instance atlanta from an action in the Timeline of charleston, you could use the following relative path:

_parent._parent.georgia.atlanta

Relative paths are useful for reusing scripts. For example, you could attach the following script to a movie clip that magnifies its parent by 150%:

onClipEvent (load) {    _parent._xscale 
= 150;    _parent._yscale = 150; 
}

You can reuse this script by attaching it to any movie clip instance.

 Flash Lite 1.0 and 1.1 support attaching scripts only to buttons. Attaching scripts to movie clips is not supported.

Whether you use an absolute or a relative path, you identify a variable in a Timeline or a property of an object with a dot (.) followed by the name of the variable or property. For example, the following statement sets the variable name in the instance form to the value "Gilbert":

_root.form.name = "Gilbert";

Using absolute and relative target paths

You can use ActionScript to send messages from one timeline to another. The timeline that contains the action is called the controlling timeline, and the timeline that receives the action is called the target timeline. For example, there could be an action on the last frame of one timeline that tells another timeline to play. To refer to a target timeline, you must use a target path, which indicates the location of a movie clip in the display list.

The following example shows the hierarchy of a document named westCoast on level 0, which contains three movie clips: california, oregon, and washington. Each of these movie clips in turn contains two movie clips.

_level0 
        westCoast 
                california 
                        sanfrancisco 
                        bakersfield 
                oregon 
                        portland 
                        ashland 
                washington 
                        olympia 
                        ellensburg

As on a web server, each timeline in Animate can be addressed in two ways: with an absolute path or with a relative path. The absolute path of an instance is always a full path from a level name, regardless of which timeline calls the action; for example, the absolute path to the instance california is _level0.westCoast.california. A relative path is different when called from different locations; for example, the relative path to california from sanfrancisco is _parent, but from portland, it’s _parent._parent.california.

Specify target paths

To control a movie clip, loaded SWF file, or button, you must specify a target path. You can specify it manually, or by using the Insert Target Path dialog box, or by creating an expression that evaluates to a target path. To specify a target path for a movie clip or button, you must assign an instance name to the movie clip or button. A loaded document doesn’t require an instance name, because you use its level number as an instance name (for example, _level5).

Assign an instance name to a movie clip or button

  1. Select a movie clip or button on the Stage.
  2. Enter an instance name in the Property inspector.

Specify a target path using the Insert Target Path dialog box

  1. Select the movie clip, frame, or button instance to which you want to assign the action.

    This becomes the controlling Timeline.

  2. In the Actions panel (Window > Actions), go to the Actions toolbox on the left, and select an action or method that requires a target path.
  3. Click the parameter box or location in the script where you want to insert the target path.
  4. Click the Insert Target Path button  above the Script pane.
  5. Select Absolute or Relative for the target path mode.
  6. Select a movie clip in the Insert Target Path display list, and click OK.

Specify a target path manually

  1. Select the movie clip, frame, or button instance to which you want to assign the action.

    This becomes the controlling Timeline.

  2. In the Actions panel (Window > Actions), go to the Actions toolbox on the left, and select an action or method that requires a target path.
  3. Click the parameter box or location in the script where you want to insert the target path.
  4. Enter an absolute or relative target path in the Actions panel.

Use an expression as a target path

  1. Select the movie clip, frame, or button instance to which you want to assign the action.

    This becomes the controlling Timeline.

  2. In the Actions panel (Window > Actions), go to the Actions toolbox on the left, and select an action or method that requires a target path.
  3. Do one of the following:
    • Enter an expression that evaluates to a target path in a parameter box.

    • Click to place the insertion point in the script. Then, in the Functions category of the Actions toolbox, double-click the targetPath function. The targetPath function converts a reference to a movie clip into a string.

    • Click to place the insertion point in the script. Then, in the Functions category of the Actions toolbox, select the eval function. The eval function converts a string to a movie clip reference that can be used to call methods such as play.

      The following script assigns the value 1 to the variable i. It then uses the eval function to create a reference to a movie clip instance and assigns it to the variable x. The variable x is now a reference to a movie clip instance and can call the MovieClip object methods.

      i = 1; x = eval("mc"+i); x.play(); // this is equivalent to mc1.play();

      You can also use the eval function to call methods directly, as shown in the following example:

      eval("mc" + i).play();

 Adobe

Get help faster and easier

New user?