Name
- Adobe Animate User Guide
- Introduction to Animate
- Animation
- Animation basics in Animate
- How to use frames and keyframes in Animate
- Frame-by-frame animation in Animate
- How to work with classic tween animation in Animate
- Brush Tool
- Motion Guide
- Motion tween and ActionScript 3.0
- About Motion Tween Animation
- Motion tween animations
- Creating a Motion tween animation
- Using property keyframes
- Animate position with a tween
- How to edit motion tweens using Motion Editor
- Editing the motion path of a tween animation
- Manipulating motion tweens
- Adding custom eases
- Creating and applying Motion presets
- Setting up animation tween spans
- Working with Motion tweens saved as XML files
- Motion tweens vs Classic tweens
- Shape tweening
- Using Bone tool animation in Animate
- Work with character rigging in Animate
- How to use mask layers in Adobe Animate
- How to work with scenes in Animate
- Interactivity
- How to create buttons with Animate
- Convert Animate projects to other document type formats
- Create and publish HTML5 Canvas documents in Animate
- Add interactivity with code snippets in Animate
- Creating custom HTML5 Components
- Using Components in HTML5 Canvas
- Creating custom Components: Examples
- Code Snippets for custom Components
- Best practices - Advertising with Animate
- Virtual Reality authoring and publishing
- Workspace and workflow
- Creating and managing Paint brushes
- Using Google fonts in HTML5 Canvas documents
- Using Creative Cloud Libraries and Adobe Animate
- Use the Stage and Tools panel for Animate
- Animate workflow and workspace
- Using web fonts in HTML5 Canvas documents
- Timelines and ActionScript
- Working with multiple timelines
- Set preferences
- Using Animate authoring panels
- Create timeline layers with Animate
- Export animations for mobile apps and game engines
- Moving and copying objects
- Templates
- Find and Replace in Animate
- Undo, redo, and the History panel
- Keyboard shortcuts
- How to use the timeline in Animate
- Creating HTML extensions
- Optimization options for Images and Animated GIFs
- Export settings for Images and GIFs
- Assets Panel in Animate
- Multimedia and Video
- Transforming and combining graphic objects in Animate
- Creating and working with symbol instances in Animate
- Image Trace
- How to use sound in Adobe Animate
- Exporting SVG files
- Create video files for use in Animate
- How to add a video in Animate
- Draw and create objects with Animate
- Reshape lines and shapes
- Strokes, fills, and gradients with Animate CC
- Working with Adobe Premiere Pro and After Effects
- Color Panels in Animate CC
- Opening Flash CS6 files with Animate
- Work with classic text in Animate
- Placing artwork into Animate
- Imported bitmaps in Animate
- 3D graphics
- Working with symbols in Animate
- Draw lines & shapes with Adobe Animate
- Work with the libraries in Animate
- Exporting Sounds
- Selecting objects in Animate CC
- Working with Illustrator AI files in Animate
- Applying blend modes
- Arranging objects
- Automating tasks with the Commands menu
- Multilanguage text
- Using camera in Animate
- Graphic filters
- Sound and ActionScript
- Drawing preferences
- Drawing with the Pen tool
- Platforms
- Convert Animate projects to other document type formats
- Custom Platform Support
- Create and publish HTML5 Canvas documents in Animate
- Creating and publishing a WebGL document
- How to package applications for AIR for iOS
- Publishing AIR for Android applications
- Publishing for Adobe AIR for desktop
- ActionScript publish settings
- Best practices - Organizing ActionScript in an application
- How to use ActionScript with Animate
- Accessibility in the Animate workspace
- Writing and managing scripts
- Enabling Support for Custom Platforms
- Custom Platform Support Overview
- Working with Custom Platform Support Plug-in
- Debugging ActionScript 3.0
- Enabling Support for Custom Platforms
- Exporting and Publishing
- How to export files from Animate CC
- OAM publishing
- Exporting SVG files
- Export graphics and videos with Animate
- Publishing AS3 documents
- Export animations for mobile apps and game engines
- Exporting Sounds
- Best practices - Tips for creating content for mobile devices
- Best practices - Video conventions
- Best practices - SWF application authoring guidelines
- Best practices - Structuring FLA files
- Best Practices to optimize FLA files for Animate
- ActionScript publish settings
- Specify publish settings for Animate
- Exporting projector files
- Export Images and Animated GIFs
- HTML publishing templates
- Working with Adobe Premiere Pro and After Effects
- Quick share and publish your animations
- Troubleshooting
Use this article to learn how to create custom components for HTML5 canvas.
Animate ships with a set of default components. However, these are insufficient for your project. This topic helps you understand how to create custom HTML5 Components for Animate.
A component definition consists of three major parts:
- Metadata: Provides information about the component such as display name, version, set of configurable properties, icon, and so on. This is captured in a file called components.js. You can group the components as a category and this file allows you to provide the meta-data for all components in a category.
- Source: Provides information about the actual component source. This is embedded at runtime when you preview or publish a movie using components.
- Assets: Provides information about any runtime dependency such as like JavaScript library or CSS or runtime assets and icons. The assets can be used in the Animate authoring environment.
A component definition also has localization-related resources.
Animate checks the following folders for any custom HTML5 Components and loads them on launch:
• Windows:
<AppData>/Local/Adobe/Adobe Animate 2017/en_US/Configuration/HTML5Components
• MAC:
~/Library/Application Support/Adobe/Animate 2017/en_US/Configuration/HTML5Components/
The above folder path is applicable for US English. If you are using Animate in any other language, look for your language specific folder name replacing en_US.
For each folder within the location that contains the file ‘components.js’, Animate creates a category, and loads all the components within.
Component Metadata
The metadata of the Component is captured in a file called components.js which is placed inside a separate folder within HTML5Components directory.
Components.js
Components.js
is a JSON file that contains the following sections:
- Category: Name in the Components Panel for this set of components and can be localized.
- Components: Array where each entry contains the metadata about a component. The above sample has only one element in the array. The metadata has following sections:
|
Required |
Description |
---|---|---|
ClassName |
Yes |
Class name of the component specified in the source file. The class name supports one level of namespaces. For example, Video.
|
Version |
No |
Version number of the component. This is used for future component upgrades. However, the flow is not defined at this point of time. |
Source |
Yes |
Relative path of the component’s main source file. More details are provided on what does the source contain in the next section. |
Icon |
No |
Relative path for the icon for the component. This icon is used in the components panel and on stage when any instance is created for the component along with its name. If none is provided a default icon will be used. You can specify the png name of the icon to be loaded (typically 32x32). Or else, if you want to support different icons for light UI and dark UI then provide two .pngs with the following naming convention: custom_icon_N.png – Icon for dark UI custom_icon_D.png – Icon for light UI and just specify the name ‘custom_icon’ as the value for this field. The suffixes are automatically appended based on the current user setting. |
Dimensions |
No |
Default size for the component instances. Whenever user drags and drops a component from Component panel to stage, a new instance is created. This field specifies the default initial size for the component instance. The value should be an array [width, height]. If there is no value specified, then Animate picks up a default size. Also Animate restricts the size to be within [2,2] to [1000, 1000] range. |
Dependencies |
No |
The set of dependencies for the component. This is an array where each entry provides the relative path for a local source (with key = “src”) and CDN path (with key=’cdn’). The CDN path is not mandatory. This path is used when you use hosted libraries in the publish settings. Otherwise the local source will be used when you preview or publish. Do note the relative path used in the example above (video). Its loading the dependencies from one level above, which allows us to share some dependencies across multiple component sets. |
Properties |
Yes |
This is an array of properties. When you create any instance of this component on stage, the set of properties configured here will be automatically shown in the PI. Users of this component can configure those properties in Animate and the configured properties are made available during instantiation of the component at runtime. Each property entry contains the following keys:
|
Component Source
Each component should have a source file associated which provides code to handle the following:
- Creation of component instance at runtime with configured set of property values
- Attaching and Detaching to the DOM.
- Property updates in every frame
A base class is provided and a utility function in the file anwidget.js for easier development of custom components. This interface will be enhanced in future but will be backward compatible. Currently only DOM- based components are supported; however support for canvas based components will be extended. Currently only widgets are supported; however, the framework will be enhanced to support attaching behaviors (non-ui components).
The file anwidget.js is present under HTML5Components/sdk folder in your first run folder. It provides a base class AnWidget for custom components and a utility method $.anwidget(<className>, {Object Prototype}) for registering a custom component. The current implementation uses jQuery, so jQuery is always added as a dependency whenever you use the services provided by a widget. However, if you do not want to add an implicit dependency on jQuery, then you may need to implement a Component class without jQuery which provides the same interface as a Widget.
The html contains these sections (excluding the preloader div) by default:
Do note that the previous figure illustrates the order in which the elements are added in the DOM. Thus the dom_overlay_container div is shown above the canvas.
Do not change the ID of the dom_overlay_container div as in our first release, there are a couple of features which depend on this ID like code snippets.
As shown in the previous illustration, the dom_overlay_container div is shown on top of the canvas as an overlay. To make sure that the mouse events are propagated properly to the underlying canvas too, we use the CSS property {pointer-events: none} for this div so that mouse events are propagated to the underlying canvas. All the component instances which are configured in Animate in your project are instantiated and attached as a child of this dom_overlay_container div. The relative ordering of the component instances are maintained at runtime, but currently all the component instances are always shown as an overlay. We set {pointer-events: all} for all the component instances at runtime so that they also receive the mouse events.
Component lifecycle
-
The component instance is created when the DOM is being constructed for the container.
-
The instance is then attached to the DOM when the playhead reaches the frame where the component instance is used. It then attaches an update handler which is called on every tick at runtime. The component also fires an event ‘attached’ at this time with the following event data {id: id_of_the_instance} on the parent element.
-
The Properties are updated in every update callback. All the property updates are cached and applied once during a tick handler. Currently custom property tweens are not supported. Only the basic properties such as transform and visibility are updated.
-
When the playhead reaches a frame where component instance is removed, we detach it from the DOM. A ‘detached’ event is fired this time on the parent element.
The base class is called $.AnWidget and provides the following overrides:
Name |
Mandatory |
Description |
---|---|---|
getCreateOptions() |
No |
Returns any options which the component wants to be applied during component instantiation. A typical override generally uses this to assign a unique ID to every instance by making use of the global variable _widgetID. The example in the next section will make its usage clear. |
getCreateString() |
Yes |
Return the string for your DOM instance creation. This string is passed to jQuery to create the actual DOM element which is attached later to the base DOM.
For example, for an image component this should return “<image>”.
At runtime the element is created and the reference to the jQuery wrapper is stored as follows in the component instance:
this._element = $(this.getCreateElement())
// this._element – jQuery wrapper for the underlying DOM element created.
We can also create composite elements; the details will be covered in an examples section. |
getProperties() |
No |
Returns an array of configurable CSS property names. Typically, this matches with all the properties you configured in components.json
For example, for the video component this array contains the following entries:
["left", "top", "width", "height", "position", "transform-origin", "transform"] |
getAttributes() |
No |
Returns an array of configurable attributes. Typically, this matches with all the attributes that you are permitted to configure in components.json
For example, for the video component this array contains the following entries:
["id", "src", "controls", "autoplay", "loop", "class"] |
attach(parent) |
No |
This function is called whenever the component instance is about to be attached to the ‘parent’ DOM element.
The default implementation does the following (and some more stuff):
// Appends the element to the parent DOM $(parent).append(this._element);
//Stores the ref in this._$this this._$this = $(this._element);
//Calls force update to apply all properties this.update(true); this._attached = true;
//Triggers the attached event on parent $(parent).trigger("attached", this.getEventData("attached"))
You do not need to override this function. However, for composite elements we may need to override it. More details will be covered in the examples section.
Note: You can use this._superApply(arguments) to call any base class method from any override. |
detach() |
No |
This function is called whenever the component instance is about to be removed from the DOM. The default implementation does the following:
//Removes the element from the DOM this._$this.remove(); //Triggers the detached event on parent $(parent).trigger("detached", this.getEventData("detached")); |
setProperty(k,v) |
No |
This function is used to set any property for the instance. These changes are cached and are applied at once during the call to update() every frame for every property which is dirty. |
update(force) |
No |
This function is called every frame when the component is part of DOM and is visible. The default implementation applies all the CSS properties and attributes which have changed or if force parameter is true. |
show() |
No |
Shows the element instance. You typically don’t need to override this, but for composite elements you may need to. |
hide() |
No |
Hides the element instance. You typically don’t need to override this, but for composite elements you may need to. |
getEventData(e) |
No |
Returns any custom data for the event with name ‘e’. The default implementation passes the data {id: instance_id} for attached and detached events. |
destroy() |
No |
Frees the memory when the component instance is detached from DOM. You typically don’t need to override this. |
applyProperties(e) |
No |
Helper API for applying the CSS properties to the jQuery wrapper e. |
applyAttributes(e) |
No |
Helper API for applying the attributes to the jQuery wrapper e. |
Localization
The category string, component display name and property name can be localized. Create a file called strings.json in a folder with the name locale under the components folder. Provide the key-value pairs for all the strings to be localized and use the key in the components.js. For other locales, you need to provide the strings in the corresponding folders under the locale folder.
Package and distribute custom HTML5 components
Animate developers or designers can enable animators to install and use components without coding, by providing ready-to-use packaged components. Previously, animators had to learn file structures, do programming, and manually move the files to specific folders to activate the HTML5 extensions.
Prerequisites
- Any component created by a developer. Click here for instructions on creating components.
- CC Extensions signing toolkit.
Before packaging your component, create an MXI file with the metadata of source and destination path of components. For example,
<file source="jquery-ui-1.12.0" destination="$FLASH\HTML5Components\jQueryUI\" file-type="ordinary" />
This source and destination file information is required to enable extensions utility for accurate installation of your component.
Packaging components
To package the HTML5 custom components, perform the following steps:
-
To create an MXI file, enter the content similar to the sample abc.mxi file using a text editor and save it with an MXI extension.
Download
-
Add your MXI component file and other associated files in a folder.
-
Create a ZXP extension zip file by using the CC Extensions signing tool (ZXPSignCmd.exe). Use the following commands in ZXP Sign Command tool to create a ZXP file:
1. Create a self-signed certificate by using the -selfSignedCert option.
You can skip this step if you already have a certificate.
ZXPSignCmd -selfSignedCert US NY MyCompany MyCommonName password FileName.p12
FileName.p12 file is generated in the current folder.
2. Sign the extension using the following command:
ZXPSignCmd -sign projectName projectName.zxp FileName.p12 password
projectName is the name of the Extension Project. In the current folder, a file with the name projectName.zxp is generated.
Distribute components
You can distribute this projectName.zxp packaged component file to any of the Animate users.
Adobe recommends that you distribute your products through the Adobe Add-ons website. You can distribute add-ons publicly (free or paid) or privately (free to named users).
Install distributed components
Animate designers or developers can install the distributed ZXP file component by using the Manage Extensions utility.