User Guide Cancel

Add interactivity with code snippets in Animate

  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

 

The Code Snippets panel is designed to make it easy for non-programmers to start using simple JavaScript and ActionScript 3.0 quickly. It lets you add code to your FLA file to enable common functionality. Using the Code Snippets panel does not require knowledge of JavaScript or ActionScript 3.0.

With the Code Snippets panel, you can:

  • Add code that affects the behavior of an object on the Stage

  • Add code that controls the movement of the playhead in the Timeline

  • (CS5.5 only) - Add code that allows touchscreen user-interaction

  • Add new code snippets that you create to the panel

Using the code snippets included with Animate is also a good way to begin learning JavaScript or ActionScript 3.0. By looking at the code in the snippets and following the snippet instructions, you can begin understanding code structure and vocabulary.

Code snippets option in Animate
Code snippets option in Animate

Before you begin

When working with the Code Snippets panel, it is important to understand these fundamentals of Animate:

  • Many of the code snippets require you to customize a few items in the code. In Animate, you can do this in the Actions panel. Each snippet contains specific instructions for this task.

  • All of the included code snippets are either JavaScript or ActionScript 3.0.

  • Some snippets affect the behavior of an object, allowing it to be clicked or causing it to move or disappear. You apply these snippets to the object on the Stage.

  • Some snippets cause an action to occur immediately when the playhead enters the frame that contains the snippet. You apply these snippets to a Timeline frame.

  • When you apply a code snippet, the code is added to the current frame of the Actions layer in the Timeline. If you have not created an Actions layer yourself, Animate adds one above all other layers in the Timeline.

  • For ActionScript to control an object on the Stage, the object must have an instance name assigned in the Property inspector.

  • You can click the Show Description and Show Code buttons that appear when you select a snippet in the panel.

Add a code snippet to an object or Timeline frame

To add an action that affects an object or the playhead:

  1. Select an object on the Stage or a frame in the Timeline.

    If you select an object that is not a symbol instance, Animate converts the object to a movie clip symbol when you apply the snippet.

    If you select an object that does not already have an instance name, Animate adds one when you apply the snippet.

  2. In the Code Snippets panel (Window > Code Snippets), double-click the snippet you want to apply.

    If you selected an object on the stage, Animate adds the snippet to the Actions panel in the frames containing the selected object.

    If you selected a Timeline frame, Animate adds the snippet to just that frame.

  3. In the Actions panel, view the newly added code and replace any necessary items according to the instructions at the top of the snippet.

Code snippet in actions panel

Add new snippets to the Code Snippets panel

You can add new code snippets to the Code Snippets panel in two ways:

  • Enter a snippet in the Create New Code Snippet dialog box.

  • Import a code snippet XML file.

To use the Create New Code Snippet dialog box:

  1. In the Code Snippets panel, choose Create New Code Snippet from the panel menu.

  2. In the dialog box, Enter the Title, Tool tip text, and JavaScript or ActionScript 3.0 code for your snippet.

    You can add any code that is currently selected in the Actions panel by clicking the Auto-Fill button.

  3. Select the Automatically replace instance_name_here check box if your code includes the string “instance_name_here” and you want Animate to replace it with the correct instance name when the snippet is applied.

    Animate adds the new snippet to the Code Snippets panel in a folder called Custom.

To import a code snippet in XML format:

  1. In the Code Snippets panel, choose Import Code Snippets XML from the panel menu.

  2. Select the XML file you want to import and click Open

To see the correct XML format for code snippets, choose Edit Code Snippets XML from the panel menu.

To delete a code snippet, right-click the snippet in the panel and choose Delete Code Snippet from the context menu.

Interactive animations with HTML5

Certain animations require snippets of code to support various publishing platform. Want to learn how to use snippets of code to make your animation interactive? Watch the tutorial at the end of this example and follow these steps.

  1. In the Library, click Publish Settings.

  2. Select JavScript/HTML.

  3. In the HTML/JS tab, click Export and choose the following options:

    • File name: Type the name of the file.
    • Save as Type: Select HTML.
  4. Click OK.

How to enhance your HTML5 interactive animations

Watch the video to know how to edit the codes.

Get help faster and easier

New user?