Search code examples
flashcanvasactionscript-2animate-cc

Including code files in HTML 5 Canvas Animate CC documents


We're currently transitioning from AS2 in CS6 to the HTML5 Canvas with Javascript in Adobe Animate CC, while trying to retain as much of the functionality we've built in AS2 over the years.

So far, the biggest thing I've not been able to replicate in any way is the #include compiler directive for AS2.

Has anyone found a solution to this problem?


Solution

  • With the latest version of Animate CC (15.1.1.13) you can edit the HTML template used for publishing easily.

    In the "Publish Settings" go to "Advanced" and export the default template. Open the exported HTML file and inject any additional JavaScript libraries after <!-- write your code here -->.

    e.g. add <script src="http://code.jquery.com/jquery-2.2.3.min.js"></script> to use jQuery.

    After saving the HTML file go back to "Publish Settings" and import your modified template with "Import New...".

    You can use this approach with your own libraries and relative paths, just make sure they are available in the directory of the output file (same as .fla by default).

    e.g. <script src="foo.js"></script>