Adobe Creative Cloud

March 30, 2016 /General /

Using Animate CC HTML5 Canvas Templates with Multiple Publish Profiles

The ability to publish to HTML5 Canvas from Animate CC (and Flash Professional before it) is nothing new… however, with the release of Animate CC we now have a number of additional options when managing how a project gets published – especially in terms of how the HTML output is constructed.


HTML5 Canvas Output

When publishing to HTML5 Canvas from Animate CC, the resulting HTML file is hugely important in terms of the project’s ultimate destination. This can be clearly seen in terms of the differing specifications which ad distribution networks expect content producers to conform to when submitting their projects.



Figure 1. We are using an HTML5 Canvas document for this project.


In the Properties Panel, we can easily see it specified that we are working on an HTML5 Canvas Document. You might also notice that the Publish Profile is listed as Default. This is an often overlooked features of Animate CC and we will be examining it later in this article.



Figure 2. The Properties Panel indicates the type of document and Publish Profile being used.


Before moving on, if we go ahead and test our document in the web browser by choosing Control > Test, we’ll see the result of this Default Publish Profile. The canvas element which is our published project is aligned to the upper left and the HTML background color is a sad grey.



Figure 3. Our content rendered using the default Publish Template.


The good news is that it doesn’t have to be this way! Let’s now go ahead and click on Publish Settings in the Properties Panel to access all of our document publish options.


HTML5 Canvas Templates

The first thing to do if you want to create a template of your own is to export the default template in order to modify it to your liking. To do so, from the Advanced tab in Publish Settings, click the Export button and save the HTML file on your machine for editing. You will be prompted by Animate CC to give this file a name and location on your hard drive.



Figure 4. Exporting the Default Template file from the Advanced Publish Settings.


With the default template exported, you will now be able to open it up in Adobe Dreamweaver, Brackets, or any text editor of your choosing to customize the HTML, JavaScript, and CSS contained within. Perhaps you want to center your HTML5 Canvas content or add other elements like headers and descriptive text. This is all possible using Templates.


Editing the Template

Now that we have our Template file open within an editor, we can make whatever modifications we wish. In this example, I’ve styled the Body element to inherit the Stage background color as defined in our Animate project. I’ve also gone ahead and given some margin to the document, and have centered the Canvas element. That should make things a bit more balanced and lively!



Figure 5. Editing the Template HTML file in Brackets.


One thing to make note of before we move on, is the availability of special tokens with the HTML Template which ca be used when customizing. For instance, tokens such as $BG, $WT, and $HT can be used in conjunction with custom logic and elements to adjust for sizing and background colors within your Template.

Here is a short list detailing some of these tokens, and what they represent:

$CANVAS_ID                    The ID of the Canvas element within your HTML document.

$TITLE                                 The title of your project document.

$BG                                       The background color of the Stage defined within the FLA.

$WT                                       The width of the Stage defined within the FLA.

$HT                                       The height of the Stage defined within the FLA.

These tokens are available for use within any Template and will be replaced by their appropriate values upon publication. Other tokens exist as well, and can be explored within the exported HTML Template file.


Using Ad Network Code within a Template

In this example, we’ve created a very visual Template in order to more easily express what can be achieved through this mechanism. However, we can also include non-visual elements within a Template as often required by various ad distribution networks.

Here, for example, is a bit of HTML to include in the HEAD of your Template in order to conform to DoubleClick ad campaign requirements.

<meta name=”ad.size” content=”width=300,height=250″>

<script type=”text/javascript”>

var clickTag = “”;


In the above code, we set the ad size though a META tag, and then expose a ClickTag variable for use within our Animate CC project. Within the actual Animate content, we can respond to user interaction by invoking the following:;

This will allow the use of ClickTag events within out HTML5 Canvas project easily through the use of Animate CC Templates! The same sort of functionality can be enabled for a variety of ad distribution networks by creating a Template for each one.


Importing the Custom Template

When you are finished editing, save your HTML and return to Animate CC and the Advanced Publish Settings. Simply click the Import New… button and locate the edited HTML file to use it within your project. The selected template is now clearly indicated within the dialog.



Figure 6. Importing the custom Template file.


Now, whenever you test or publish your HTML5 Canvas document, it will employ your custom Template in place of the default. If at any time you wish to use the default Template again, simply click the Use Default button.


Publish Profiles

What if you have a number of Templates which you wish to switch between when publishing your content? It would be a pain to have to import Template files every time you need to switch. This is where Publish Profiles come into play.

To establish the Template just created as part of a Profile, you can click the gear icon and choose to Create profile.



Figure 7. Creating a custom Profile.


A small dialog will appear, allowing you to provide a name for this profile. In this manner, you can define any number of Profiles in your document and easily switch between them.



Figure 8. Naming the new Profile.


With a custom Profile defined in the project, you can now switch between that and the default with ease by simply choosing it by name from the dropdown. Note as well that these can be exported and imported to share between projects!


Employing Templates by Swapping Profiles

Templates can be automatically applied to your content prior to publication by assigning a specific Template to a Profile, and then switching to whichever Profile you want to use. This action will employ the specific Template applied within that Profile to the document being published.

For the last part of this article, I’ll go ahead and switch my Publish Profile to new newly created “Center Content + BGProfile by selecting it from the Profile dropdown in the Advanced tab of our Publish Settings dialog.



Figure 9. Switching Publish Profiles.


Clicking the OK button within our Publish Settings will apply the selected Profile and return us to the project document. Notice that the Properties Panel now reflects the selected Profile and no longer the default.



Figure 10. Selected Profile is indicated in the Properties Panel.


From here, we can once again test the project in the web browser by choosing Control > Test. The compiled HTML5 Canvas project will appear in a new browser window and the changes will become obvious with the entire background inheriting the Stage color chosen in Animate CC and the content itself perfectly centered – much nicer!



Figure 11. Published content using the custom Template and Profile


To return to the Default Profile or to manage and select other Publish Profiles, simply return to the Publish Settings dialog.



Join the discussion

  • By david - 8:20 AM on March 30, 2016  

    cool – Is it possible to publish HTML5 canvas to a desktop app like AIR or something else?

    • By Joseph - 10:01 AM on March 30, 2016  

      Hi David. Yes, you can incorporate HTML5 Canvas output within Apache Cordova and Adobe PhoneGap for mobile app development.

  • By Misha - 8:22 AM on March 30, 2016  

    I manually edit the HTML document to make banner responsive. For example: . It will be good if Animate will has a responsive size function.
    Thank you.

    • By Ajay Shukla - 9:29 PM on April 3, 2016  

      We are working on it as we speak. 🙂


  • By somnamblst - 11:31 AM on April 11, 2016  

    I am having way too many issues with Publish Profiles not working for me, to not suspect that Enterprise Security/proxy issues are to blame. Cory Hudson’s adStarter FLA previews blank when I use the custom Publish Profile he created. It is fine when I change it to default.

  • By Jaski - 7:39 AM on April 13, 2016  

    I would like images to stay vector when i publish a html5 canvas document. Will it be possible soon?

    • By Marjan - 2:32 PM on May 5, 2016  

      No, it is not possible because Canvas is pixel dependent. Vectors stay vectors in JavaScript but you can only viewing it through pixel dependent Canvas.

  • By Dan - 6:10 PM on May 26, 2016  

    I’m finding that if you create an HTML template and attach it to a Publish Profile, and then export that Profile and import it into another Canvas FLA, it does not keep a link to the custom HTML template. Is that expected?

    • By Ajay Shukla - 9:30 PM on May 26, 2016  

      That is correct. We are working on fixing this. You will need to re-import the custom HTML template for now. Alternatively, you can use the fla as a template.


      • By Dan - 11:46 AM on May 27, 2016  

        Yeah that would be pretty helpful. Also a way to create a document from a template using JSFL.

      • By Marc - 7:30 PM on June 8, 2016  

        Ajay – correct me if I’m wrong, but building a Canvas project currently processes any PNG and JPGs when moving them to the designated folder. It’d be nice to have an option to bypass this and allow Animate to just move the files over without compressing/changing them. Reason being – we’ve had better results compressing PNGs through PNGQuant and JPGs through 3rd party apps like Nero.

        • By Ajay Shukla - 9:29 PM on June 8, 2016  

          You can use your recommended workflow even today. After publishing once, go to publish settings and uncheck “Export Image Assets”. You can replace images assets in this folder with the ones you’ve optimized outside and use them in your final composition. Hope this helps.


  • By Pankaj - 3:53 AM on June 15, 2016  

    I have created an ad which has quite a lot vector elements from animate.The ad runs smoothly when I publish it but when we upload it for testing, the animation becomes very jerky. Can anyone help me with this issue?