10. Publishing


Lesson Overview

Understand runtime environments

Understand the output files for different Animate document types

Modify publish settings

Create classic tweens for HTML5 animation

Insert and edit JavaScript in the Actions panel

Use HTML5 Canvas snippets

Convert an existing ActionScript 3.0 document to an HTML5 Canvas document

Publish an Adobe AIR application for the desktop

Publish a projector for Windows and Mac OS

Test mobile interactions in the AIR Debug Launcher

Understand publishing for the iPhone or Android

Image

This lesson will take approximately 90 minutes to complete. If you don’t yet have the project files for this lesson, download them from the Registered Products tab on your Account page at www.peachpit.com (click the Access Bonus Content link) and store them on your computer in a convenient location, as described in the Getting Started section of this book. Your Account page is also where you’ll find any updates to the lessons or to the lesson files.


A screenshot shows the "Restaurant Guide" poster and animated banner for the city of Meridien on a desktop along with the "Meridien X challenge" game poster on a mobile phone.

Use the various document types in Adobe Animate CC to create content that targets a variety of platforms and uses, including HTML5 multimedia for the web browser, multimedia for Flash Player, desktop applications, high-definition video, or mobile device apps. Put your content everywhere while still leveraging Animate’s powerful and familiar animation and drawing tools.

Understanding Publishing

Publishing is the process that creates the required file or files to play your final Adobe Animate CC project for your viewers. Keep in mind that Animate CC is the authoring application, which is a different environment from where your viewers experience your movie. In Animate CC, you author content, which means you’re creating art and animation, and adding text, videos, sound, buttons, and code. In the target environment, such as a desktop browser or a mobile device, your viewers watch the content when it plays back, or runs. So developers make a distinction between “author-time” and “runtime” environments.


Image Note

If you have not already downloaded the project files for this lesson to your computer from your Account page, make sure to do so now. On that page you’ll also find a downloadable Supplement to this lesson that contains information on bonus topics. See Getting Started at the beginning of the book.


Animate can publish content to various runtime environments, and your desired runtime environment determines the Animate document that you must choose when you first begin a project.

Document types

You learned about the various Animate document types in Lesson 1, and you’ve worked with a few of them throughout the projects in this book. For example, you started an HTML5 Canvas document for Lesson 2, an ActionScript 3.0 document for Lesson 8, and an AIR for Desktop document for Lesson 9. Each project publishes a different set of files for their targeted runtime environment, but each project is saved as an FLA or XFL (Animate) file that you edit in Animate CC.

In this lesson, you’ll explore the publishing options for the document types in greater detail. You’ll work through an interactive HTML5 Canvas animation, and you’ll learn to create desktop applications.

Runtime environments

If an ActionScript 3.0 document is published to SWF and is played back with the Flash Player in a desktop web browser, then the Flash Player is the runtime environment for that ActionScript 3.0 document. Flash Player 23 is the latest version and supports all the new features in Animate CC. The Flash Player is available as a free plug-in from the Adobe website for all the major browsers and platforms. In Google Chrome, Internet Exporer, and others, the Flash Player comes preinstalled and updates automatically.


Image Note

The ActionScript 3.0 document also supports publishing content as a projector for either Macintosh or Windows. A projector plays as a stand-alone application on the desktop, without needing a browser.


If you want to target web browsers without requiring the Flash Player, then begin your Animate project with an HTML5 Canvas or WebGL document. To integrate interactivity into an HTML5 Canvas document, you use JavaScript rather than ActionScript. You can add JavaScript directly in the Actions panel or use HTML5 Canvas snippets.

Adobe AIR is another runtime environment. AIR (Adobe Integrated Runtime) runs content directly from your desktop, without the need for a browser. When you publish your content for AIR, you can make it available as an installer that creates a stand-alone application, or you can build the application with the runtime already installed, known as “captive runtime.”

You can also publish AIR applications as mobile apps that can be installed and run on Android devices and iOS devices such as the Apple iPhone or iPad, whose browsers do not support the Flash Player.


Image Note

Not all features are supported across all document types. For example, WebGL documents don’t support text and HTML5 Canvas documents don’t support the 3D Rotation and Translation tools. Unsupported tools are grayed out.



Image Note

You can’t easily switch from one document type to another. For example, you can’t convert an HTML5 Canvas document into a WebGL document. However, you can use standard copy and paste commands to move your content from one document to another. The exception is converting an ActionScript 3.0 document into an HTML5 Canvas or WebGL document, which Animate does support.


Publishing for Flash Player

When you publish for Flash Player with an ActionScript 3.0 document, you publish two files: a SWF file and an HTML document that tells the web browser how to display the SWF file. You need to upload both files to your web server along with any other files your SWF file references (such as any video files and skins). By default, the Publish command saves all the required files to the same folder.


Image Tip

When you change the settings in the Publish Settings dialog box, Animate saves them with the document.


You can specify different options for publishing a movie, including whether to detect the version of Flash Player installed on the viewer’s computer.

Specifying publish settings for Flash Player

You can determine how Animate publishes the SWF file, including which version of Flash Player it requires, and how the movie is displayed and plays.

1. Open the 10Start_banner.fla file, a simple animated banner for the fictional city of Meridien.

A screenshot shows the animated banner for the fictional city of Meridien.

2. Choose File > Publish Settings. Alternatively, make sure no object is selected on the Stage so the Properties panel displays the Document properties. Then in the Publish section, under Profile click Publish Settings.

A screenshot shows Document Properties tab where "Publish Settings" button is circled under Default profile in the Publish section.

Image Note

In general, it’s better to control an Animate movie with code than to rely on the Playback settings in the Publish Settings dialog box. For example, add a this.stop() command in the very first frame of your Timeline if you want to pause the movie at the start, or a this.gotoAndPlay(1) or this.gotoAndPlay(0) at the end of your Timeline if you want the movie to loop. When you test your movie (Control > Test), all the functionality will be in place.


The Publish Settings dialog box opens, showing the general settings at the top, the formats on the left, and additional options for selected formats on the right.

A screenshot shows Publish Settings dialog box.

The Animate (.swf) and HTML Wrapper formats should already be selected.

3. At the top of the Publish Settings dialog box, choose a version of Flash Player from the Target menu.

A screenshot shows "Flash Player 23" selected in the Target menu at the top of the Publish settings dialog box.

Image Note

To learn how to set up your published movie to detect the version of Flash Player on the end-user’s machine, see “Detecting the version of Flash Player” in the Supplement to this lesson.


Some Animate CC features will not play as expected if you don’t choose the latest version of the Flash Player. Choose an earlier version of the Flash Player only if you’re targeting a specific audience that does not have the latest version.

4. Note that the ActionScript settings are for version 3.0, which is the latest and only version supported by this release of Animate.

5. Select the Flash (.swf) format on the left side of the dialog box.

The options for the SWF file appear on the right. Expand the Advanced section to see more options, if it isn’t already expanded.

6. If you wish, you can modify the output filename and location by entering a new filename. For this lesson, leave Output Name set to 10Start_banner.

A screenshot shows "10Start_banner" selected in the Output name menu.

7. If you’ve included bitmaps in your movie, you can set a global quality setting for JPEG compression levels. Enter a value from 0 (lowest quality) to 100 (highest quality). The value of 80 is the default, which you can leave as is for this lesson.


Image Tip

In the Bitmap properties dialog box for each imported bitmap, you can choose to use the JPEG Quality set in the Publish Settings dialog box, or choose a setting unique for that bitmap. This allows you to publish higher-quality images where you need it—for example, in photos of people—and lower-quality images where you can get away with it—for example, in background textures.


A screenshot shows the following options selected for Audio Settings: Audio Stream: MP3, 16 kbps, Mono Audio Event: MP3, 16 kbps, Mono

8. If you’ve included sound, click the Audio Stream or Audio Event value to modify the quality of the audio compression.

The higher the bit rate, the better the sound quality will be. As you’ll recall, in Lesson 9 you explored the settings for audio quality. In this interactive banner, there is no sound and thus no need to change the settings.

9. Make sure Compress Movie is selected to reduce file size and download times.

A screenshot shows a few Advanced settings selected in the Publish settings dialog box.

Deflate is the default option. Choose LZMA for better SWF compression. You’ll see the biggest improvements in file-size compression if you’ve built your project with more ActionScript code and vector graphics.

10. Select the HTML Wrapper format on the left side of the dialog box.

A screenshot shows the format selections in the Publish settings dialog box.

Image Note

To learn how to change the way your movie is displayed in your user’s browser, see “Changing display settings” in the Supplement to this lesson.


11. Make sure that Flash Only is chosen from the Template menu.


Image Tip

To learn about other template options, select one and then click Info.


Publishing for HTML5

HTML5 is the latest version of the HTML specification for marking up web pages for the browser. HTML5, along with CSS3 and JavaScript, are the modern standard for creating content for the web on the desktop, mobile phones, and tablets. Choosing the HTML5 Canvas document type in Animate targets HTML5 as the published runtime and outputs a collection of HTML5 and JavaScript files.

What is HTML5 Canvas?

Canvas refers to the canvas element, a tag in HTML5 that allows JavaScript to render and animate 2D graphics. Animate CC relies on the CreateJS JavaScript libraries to generate the graphics and animations inside the canvas element of the HTML5 project.

What is CreateJS?

CreateJS is a suite of JavaScript libraries that enable rich, interactive content with HTML5. CreateJS itself is a collection of several separate JavaScript libraries: EaselJS, TweenJS, SoundJS, and PreloadJS.

EaselJS is a library that provides a display list that allows you to work with objects on the canvas in the browser.

TweenJS is a library that provides the animation features.

SoundJS is a library that provides functionality to play audio in the browser.

PreloadJS is a library that manages and coordinates the loading of content.

With CreateJS, Animate CC generates all the necessary JavaScript code to represent your images, graphics, symbols, animations, and sounds on the Stage. Animate also outputs dependent assets, such as images and sounds. You can easily configure how those image and sound assets are organized in the publish settings.

You can also include your own simple JavaScript commands directly in the Actions panel to control your animation. Those JavaScript commands get exported in the JavaScript files.

Learn more about the CreateJS JavaScript libraries at www.createJS.com.

Using Classic Tweens

While all animation techniques (motion tweens, shape tweens, and animations with the Bone tool) are supported in HTML5 Canvas documents, the CreateJS libraries convert those animations to frame-by-frame animations, which increases the size of the JavaScript file that powers the animation.

Classic tweens, an older way of creating animation, are retained as a runtime tween, which saves file size and gives you the opportunity to control the animation dynamically via JavaScript. In this section, you’ll learn to create classic tweens to complete a sample bird animation that you’ll export to HTML5.

Classic tweening is an older approach to animation, but it is very similar to motion tweening. Like motion tweens, classic tweens use symbol instances. Changes to the symbol instances between two keyframes on the Timeline are interpolated to create the animation. You can change an instance’s position, rotation, scale, transformation, color effect, or even the filter effect if the symbol is a Movie Clip.

The key differences between classic tweens and motion tweens are as follows:

Classic tweens require a separate Motion Guide layer to animate along a path.

Classic tweens are not supported in the Motion Editor.

Classic tweens don’t support 3D rotations or translations.

Classic tweens are not separated on their own tween layer. However, classic and motion tweens share the same restriction that no other object can exist in the same layer as the tween.

Classic tweens are Timeline-based, and not object-based, meaning you add, remove, or swap the tween or the instance on the Timeline and not the Stage.

Learning to create animation with classic tweens will help you maintain leaner animation sizes when you publish to HTML5 Canvas.

Understanding the project file

Open the Animate file 10Start_build.fla, which is an HTML5 Canvas document of a bird animation. Save the file as 10_workingcopy_build.fla. The file already contains the assets for the bird animation. The animation is partially complete, and an instance of the movie clip of the bird animation is on the Stage. In this section, you’ll add the animation of the scrolling background with classic tweens, add simple interactivity with JavaScript, and publish the animation as HTML content.

Creating the movie clip symbol

You’ll add an animation of scrolling mountains inside a movie clip symbol on the main Timeline.

A screenshot shows a new layer labeled as "landscape" inserted between bird and sky layers in the main Timeline of the Publish settings dialog box.

1. On the main Timeline, insert a new layer, and name it landscape. Drag the new layer below the bird layer but above the sky layer.

2. Choose Insert > New Symbol (Ctrl+F8/Command+F8).

The Create New Symbol dialog box appears.

3. Enter scrolling landscape for the name, and choose Movie Clip from the Type menu.

A screenshot shows "scrolling landscape" entered in Name field, and "Movie Clip" option selected in Type menu of "Create New Symbol" dialog box.

4. Click OK.

The new movie clip symbol named scrolling landscape opens in symbol-editing mode. The Stage is blank, indicating that the movie clip symbol is currently empty.

5. Drag the graphic symbol called mountains from the Library panel to the Stage and position it so its lower-left corner aligns with the registration point of the movie clip symbol. In the Properties panel, in the Position And Size section, the position coordinates should read X=0, Y=−155.55.

A screenshot shows the X and Y coordinates for the position of a graphic symbol in the Properties panel.

6. Add frames (Insert > Timeline > Frame, or F5) up to frame 30.

A screenshot shows a frame added between 1 and 30, for Layer 1 of the movie-clip symbol.

Inserting a keyframe and changing the instance

You’ll add another keyframe for the mountains, so you’ll have an initial keyframe for the mountains at its starting position, and an ending keyframe when the mountains are moved to the left.

1. Select frame 30 in Layer 1 of your movie clip symbol, and insert a new keyframe (Insert > Timeline > Keyframe, or F6).

A new keyframe containing a copy of the mountains instance is inserted at frame 30.

A screenshot shows a new keyframe inserted at frame 30 in Layer 1 of the movie-clip symbol.

2. At frame 30, move the instance of the mountain graphic symbol to the left so the midpoint of the mountains image is centered over the registration point. The Properties panel should show X=−800.

The left and right edges of the graphic match up, so when the animation plays as a loop, the effect is a seamless scrolling mountain range.

A screenshot shows the X and Y coordinates for the position of mountains graphic symbol in the Properties panel.

Applying a classic tween

Apply a classic tween to the Timeline between two keyframes.

1. Right-click any frame between the first and second keyframe and choose Create Classic Tween.

A screenshot shows the right-click options for any frame in Layer 1.

Animate creates a tween between the first and second keyframe, indicated by an arrow extending along a blue background.

A screenshot shows a tween created between the first and second keyframe, indicated by an arrow extending along a blue background between the two keyframes.

2. Press Enter/Return on your keyboard, or press the Play button under the Timeline to preview the animation.

A smooth animation plays, showing the mountains moving from right to left.

3. Select Loop at the bottom of the Timeline and choose Marker Range All from the Modify Markers menu to play back the Timeline tween in a loop.

A screenshot shows the "Modify Markers menu" options displayed to playback the Timeline tween in a loop.

4. To add a little more complexity to the animation, you’ll add a second layer of mountains. Insert a new layer, and drag it under the existing layer.

A screenshot shows "Layer 2" added under Layer 1 at the 15th frame in the Timeline panel.

5. Drag another instance of the mountains symbol to the Stage, and in the Properties panel, in the Position And Size section, make sure that the Lock Width And Height icon is broken and change the width (W) to 2000 pixels and the height (H) to 200 pixels. Position the lower-left corner of the instance at the registration point of the symbol so the Properties panel shows X=0, Y=−200.

A screenshot shows the position and size options selected for the second instance of mountains graphic symbol in the Properties panel.

You’ll have two mountain ranges, with the taller and wider one behind the first one.

A screenshot shows the animation of two mountain ranges, green in color, with the second mountain range being taller and wider than the first one.

6. Insert a new keyframe (Insert > Timeline > Keyframe, or F6) at frame 30 of the bottom layer.

A screenshot shows a new keyframe inserted at frame 30 in Layer 2 of the movie-clip symbol.

7. In the end keyframe at frame 30, move the mountains instance to x=1000.

8. Right-click any frame between the first and second keyframe, and choose Create Classic Tween.

A screenshot shows a classic tween created between the first and second keyframe for Layer 2, indicated by an arrow extending along a blue background between the two keyframes.

9. Press Return/Enter on your keyboard, or press the Play button under the Timeline to preview the animation. Select the Loop option to play the tween as a loop.

The second mountain instance moves from right to left, but it’s slightly offset from the one in the foreground, creating a rich layered effect. Zoom in to the Stage so the edges of the graphics aren’t visible; this will give you a better idea of the seamless scrolling effect.

A screenshot shows the preview of the Mountain animation.

10. Exit symbol-editing mode to return to the main Timeline.

Adding the movie clip instance

Now that you’ve completed the classic tweens of the scrolling mountains, you’ll add the movie clip symbol to the main Stage.

1. Drag the movie clip symbol named scrolling landscape from the Library panel to the Stage and position the instance so its left and bottom edges align with the left and bottom edges of the Stage. In the Properties panel, in the Position And Size section, the values should read X=0, Y=400.

A screenshot shows the preview of the Scrolling mountains movie clip.

Image Note

Animation by Chris Georgenes (keyframer.com). Used with permission.


2. Save your finished work.

Your final project contains two movie clip instances, each containing multiple classic tweens.

Exporting to HTML5

The process to export your animation to HTML5 and JavaScript is straightforward.

1. Choose File > Publish.

Animate exports the animation as HTML and JavaScript files and saves them in the same folder as your FLA file (according to the default Publish Settings options).


Image Note

To learn more about the files produced when you export a move to HTML5, see “Understanding the HTML5 output files” in the Supplement to this lesson.


2. Double-click the HTML file, named 10_workingcopy_build.html.

A screenshot shows the animation file saved in HTML5 and JavaScript.

Your default browser opens and plays the animation.

Publish settings

The Publish Settings dialog box lets you change where your files are saved and how they are saved.

1. Click Publish Settings in the Properties panel, or choose File > Publish Settings to open the Publish Settings dialog box.

A screenshot shows the Publish Settings dialog box in the Properties panel.

2. On the Basic tab, do one or more of the following:

Deselect Loop Timeline if you want the Timeline to play only once.

Click the folder icon next to the Output Name field to save your published files to a different folder or under a different filename.

Change the paths next to the Export Asset Options if you want to save your assets to a different folder. The Images checkbox must be selected if your file contains images, and Sounds must be selected if your file contains sounds. For example, if you replaced the gradient fill for a bitmap image in the sky layer of your 10_workingcopy_build.fla file, upon export Animate creates a folder named images that contains the bitmap image.

Select Center Stage to center-align your Animate project in the browser window. You can use the menu next to the option to choose to center your movie Horizontally, Vertically, or Both.

Select Make Responsive to have your Animate project respond to changes in the browser window dimensions, and use the menu next to the option to choose whether the project responds to changes in window height, width, or both. The Scale To Fill Visible Area option determines how your project fills the available space in the browser window.

Select Include Preloader.

3. Select the Advanced tab:

A screenshot shows the Advanced tab settings in Publish Settings dialog box.

Select Include JavaScript In HTML if you want to publish a single file that includes all the necessary JavaScript and HTML code for your file. If you choose this option, Animate will overwrite the exported file each time you publish.

Deselect the Overwrite HTML File On Publish if you want to preserve the HTML file and simply change the JavaScript code that gets generated that drives your animations.

The Hosted Libraries option tells your published file where to find the CreateJS JavaScript libraries. When the option is selected, your published file points to a CDN (Content Distribution Network) at http://code.createjs.com to download the libraries. When the Hosted Libraries option is deselected, Animate includes the CreateJS JavaScript libraries as separate documents that must accompany your project files.

Leave all the other Advanced JavaScript Options at their default settings.

4. Select the Spritesheet tab:

A screenshot shows the Spritesheet tab settings in Publish Settings dialog box.

Select Combine Image Assets Into Spritesheets if you want to create a single image file for all the bitmaps that you’ve imported into your library. An HTML5 web page can load a single image file and retrieve specific portions of the image quicker than multiple smaller images.

Select a Format option for the exported image and set the quality, size, and background color for the image. If you choose a size that’s too small to fit the images in your library, Animate will publish multiple sprite sheets as needed.

5. Click OK to save all your settings.


Image Note

If you select the Combine Into Spritesheets option on the Basic tab, in the Export Image Assets section, the Combine Image Assets Into Spritesheets option will also be checked in the Advanced tab, and vice versa.



Image Note

You can publish a transparent Stage from an HTML5 Canvas document. In the Properties panel, in the Properties area, choose the selection with a diagonal red line indicating “no color” for the Stage.


Inserting JavaScript

If you want to add interactivity to your project, you can add JavaScript directly in the Actions panel. That JavaScript will be exported to the published JavaScript files.

Using HTML5 Canvas code snippets

Don’t worry if you’re not a JavaScript programmer. Animate CC makes it easy to add interactivity by providing common and easily modified JavaScript code in the Code Snippets panel.

Adding a response to a click

Use the HTML5 Canvas code snippets from the Code Snippets panel as you would the AS3 code snippets. In this section, you’ll add simple interactivity and make the flying bird respond to a mouse click.

1. Choose Window > Code Snippets.

The Code Snippets panel opens.

A screenshot shows three folders displayed in the Code Snippets panel as follows: ActionScript HTML5 Canvas WebGL

2. Click the arrow in front of the HTML5 Canvas folder.

The folder expands to show the code snippets organized in folders according to their function.

A screenshot shows the subfolders under HTML5 Canvas folder in the Code Snippets panel.

3. Open the Event Handlers folder.

A screenshot shows the following four events under HTML5 Canvas > Event Handlers: Mouse Click Event Mouse Over Event Mouse Out Event Double Click Event

4. Select the instance of the bird movie clip on the Stage; then double-click Mouse Click Event in the Event Handlers folder.

A screenshot shows the animation image of the bird movie clip, next to the Code Snippets panel where "Mouse Click Event" is selected under HTML5 Canvas > Event Handlers.

Animate warns you that your movie clip instance requires a name and offers to provide a name for you.

A screenshot shows a confirmation message for adding an instance name.

5. Click OK.

Animate automatically names your movie clip instance and adds JavaScript code in the Actions panel. The code is extensively commented to explain how the code works.

A screenshot shows the JavaScript code added in the Actions panel.

A new layer, named Actions, is added to the Timeline with a tiny letter “a” in the first keyframe, indicating the location of the new code on the Timeline.

The JavaScript code appears very similar to the following:

A screenshot shows a new layer labeled as "Actions" added to the timeline above the existing layers of bird, landscape and sky. A letter "a" is displayed in the first keyframe for this layer.

this.movieClip_2.addEventListener(“click”, fl_MouseClickHandler.bind(this));
function fl_MouseClickHandler ()
{
 // Start your custom code
 // This example code displays the words “Mouse clicked” in the Output panel.
 alert(“Mouse clicked”);
 // End your custom code
}

6. The JavaScript code adds an event listener for a mouse click on the instance of the bird. When a click happens, the alert() JavaScript command is triggered, which displays a simple message in a native alert dialog box in the browser.

7. Choose Control > Test to test your newly inserted interactivity.

Animate exports HTML5 and JavaScript and displays the animation in a browser.

8. Click the flying bird in the browser.

A browser dialog box appears with the words “Mouse clicked.”

A screenshot shows the animation image of the bird movie clip, with a browser dialog box displayed next to it. The dialog box displays the following: This page says: Mouse clicked Ok(button)

9. Click OK to dismiss the dialog box, and close the browser window.

Controlling the Timeline

Now you’ll add a little more complexity to your project. You’ll add more JavaScript that controls the Timeline of the flying bird.

1. Select the bird movie clip on the Stage.

2. In the HTML5 Canvas > Actions folder of the Code Snippets panel, double-click the Stop A Movie Clip snippet.

A screenshot shows the animation image of the bird movie clip, next to the Code Snippets panel where "Stop a Movie Clip" option is selected under HTML5 Canvas > Actions.

The Actions panel shows that JavaScript code has been added to the movie. The new code stops the Timeline of the bird movie clip instance.

A screenshot shows the JavaScript code added to stop the movie clip, in the Actions panel.

However, the code is triggered immediately. You want the animation of the bird to stop only when the user clicks the bird.

3. Select the newly inserted code, and choose Edit > Cut (Ctrl+X/Command+X).

4. Place your cursor inside the curly braces of your function, and choose Edit > Paste (Ctrl+V/Command+V).

With the pasted code, the command to stop the Timeline of the bird animation happens only after a mouse click is detected.

A screenshot shows the code to stop the movie inserted inside the MouseClickHandler function in the Actions panel.

5. Choose Control > Test to test interactivity.

Animate exports HTML5 and JavaScript and displays the animation in a browser.

6. Click the flying bird in the browser.

The bird stops flapping its wings, and a browser dialog box appears with the words “Mouse clicked.” The scrolling mountains in the background continue to move, however.


Image Note

The CreateJS JavaScript libraries that drive the publishing process reference timelines starting with frame numbers at 0, whereas Animate and ActionScript start with frame numbers at 1. Therefore, frame numbers in your exported JavaScript code are one less than what you would expect to see in Animate. Because of this difference, Adobe recommends that you always use frame labels instead of frame numbers for Timeline navigation. Keep this in mind when you use the gotoAndStop() or gotoAndPlay() command to control the playhead of the Timeline.



Image Note

The Actions panel color-codes your JavaScript just as it would your ActionScript code in an ActionScript 3.0 document. Use color-coding to help make sure your code is clean and error-free.



Image Tip

Use the Format Code command to clean up the appearance of your code for a consistent, easy-to-read style. Change the formatting preferences by choosing Edit > Preferences (Windows) or Animate CC > Preferences (Mac), and then selecting Code Editor.



Image Note

Remember that an ActionScript 3.0 document doesn’t necessarily contain ActionScript 3.0. An ActionScript 3.0 document is simply an Animate document that publishes for the Flash Player in a browser. An ActionScript 3.0 document can consist of animation only.


Converting to HTML5 Canvas

You may have many old animations that you created in Flash Professional that a client wants to use as HTML5 animations. Don’t worry; you don’t have to redo all your work. Fortunately, Animate CC includes options to convert existing Flash ActionScript 3.0 documents into HTML5 Canvas documents so your animations can reach the widest audience.

There are two approaches to creating an HTML5 Canvas document with Animate assets. First, you can simply create a new HTML5 Canvas document and copy and paste the layers from one file to your new file. Second, you can open your old Flash file (an ActionScript 3.0 document) and choose Commands > Convert To Other Document Formats. Animate makes the conversion, and you can save your new file as an HTML5 Canvas document.

Converting an AS3 document to an HTML5 Canvas document

You’ll convert an animation that you built as an ActionScript 3.0 document in a previous lesson to an HTML5 Canvas document.

1. Open the 10Start_convert.fla file in the 10Start folder.

A screenshot shows the animation project of the fictional movie "Double Identity" along with the timeline and various layers.

The project is the animated promotion of the fictional movie Double Identity from a previous lesson. The ActionScript 3.0 document contains bitmaps and motion tweens with changes in position, scale, color effects, 3D effects, and filters.

The file targets the Flash Player. The frame rate is set at 30 frames per second, with a black Stage fixed at a generous 1280 pixels in width and 787 pixels in height.

2. Choose Commands > Convert To Other Document Formats.

A screenshot shows the Commands menu where "Convert to Other Document Formats" option is selected.

In the dialog box that appears, choose HTML5 Canvas from the Convert Your Document To menu and enter the new filename as 10_workingcopy_convert.fla.

A screenshot shows the dialog box where the user can select the format to convert the document.

3. Click OK.

Animate duplicates your content into a new HTML5 Canvas document. The new HTML5 Canvas document contains your converted content.

4. View the warnings in the Output panel.

The screenshot displays the warning message in the Output panel.

The Output panel displays the following warning:

* 3D cannot be imported in HTML5 Canvas document.

The HTML5 Canvas document does not support either the 3D Rotation or the 3D Translation tool, so the tween does not display. Keep an eye out for the messages in the Output panel to make sure you understand how Animate handles the transition of your content from Flash Player to HTML5, and what features are unsuccessfully ported over. Often, you’ll have to do additional edits to your animation after each conversion.

5. Choose Control > Test to test the converted content.

Animate exports HTML5 and JavaScript and displays the animation in a browser. The converted animation plays, showing all the motion tweens, including the nested animations of the idling cars. The 3D animation of the title, which is unsupported, appears at the end without any animated effects.


Image Note

To learn how to replace the 3D rotation of the title (which isn’t supported in HTML5) with a scale animation, see “Editing the converted HTML5 Canvas” in the Supplement to this lesson.


A screenshot displays the converted animation image of the movie poster.

The Output panel displays additional warnings regarding features included in the animation.

Understanding image assets

Unlike the previous project in this lesson of the flying bird that uses vector graphics, this animated sequence uses bitmap images. Images imported into the Animate library must be exported so they are accessible to the HTML and JavaScript documents.

1. Examine the folder on your desktop where you saved your Animate file, 10_workingcopy_convert.fla.

A screenshot shows the images folder where the individual bitmap assets of the animation are saved as a single png image.

Animate has created an additional folder named images. Inside the images folder are all the bitmap assets for the animation saved as a single PNG image. The JavaScript code in your exported documents dynamically loads just the images that it needs to display from the single PNG image, called a sprite sheet.


Image Note

You were introduced to sprite sheets in Lesson 4.


2. Return to the Animate CC application.

A screenshot shows the Publish Settings dialog box where the name and path of the folder for all the bitmap images can be set.

3. Choose File > Publish Settings.

The Publish Settings dialog box appears. On the Basic tab, the Export Image Assets option lets you set the path and name of the folder that contains all your bitmap images.

If Export Image Assets is deselected, Animate will still export and play an animation, but without any images.

Close the Animate file. Next, you’ll learn about publishing an application to play on a computer desktop.

Publishing a Desktop Application

Most desktop computers have the Flash Player installed with their browsers, but you may want to distribute your movie to someone who doesn’t have the Flash Player or who has an older version. Perhaps you just want your movie to run without a browser.

You can output your movie as an AIR file, which installs an application on the user’s desktop. Adobe AIR is a more robust runtime environment that supports a broader range of technologies.

Viewers must download the free Adobe AIR runtime from Adobe’s website at http://get.adobe.com/air/. Alternately, you can output an AIR project with the Captive Runtime option, which includes the AIR runtime so your audience doesn’t need to download anything additional.

Creating an AIR application

Adobe AIR allows your viewers to see your Animate content on their desktop as an application. You’ll recall that in Lesson 9, the final project was a desktop application of an interactive zoo kiosk. In this section, you’ll specify the necessary publish settings to create a desktop application of a restaurant guide.

1. Open 10Start_restaurantguide.fla.


Image Note

If you open an FLA file that was created on another computer, Animate may warn you that your computer doesn’t have the same fonts that were used to build the file. Click OK in the alert dialog box to accept the substitute fonts suggested by Animate.


A screenshot highlights the edit option for Target menu in the Properties panel.

This is the same interactive restaurant guide that you created in a previous lesson, with a few modifications to the background image.

2. In the Properties panel, in the Publish section, note that AIR 23.0 For Desktop is chosen from the Target menu.

3. Click the Edit Application Settings button (wrench icon) next to the Target menu.

The AIR Settings dialog box appears.

A screenshot shows the contents of the General tab in AIR Settings dialog box.

Image Tip

You can also open the AIR Settings dialog box from the Publish Settings dialog box. Click the Player Settings button (wrench icon) next to the Target menu.


4. Examine the settings on the General tab.

The Output File field shows the filename of the published AIR installer as 10Start_restaurantguide.air. The Output As options provide three ways to create an AIR application. The first choice, AIR Package, should be selected; here is a description of what each option does:

AIR Package creates a platform-independent AIR installer.

Windows Installer (Windows)/Mac Installer (Mac) creates a platform-specific AIR installer.

Application With Runtime Embedded creates an application without an installer or the need for the AIR runtime to be installed on the end user’s desktop.

5. In the App Name/Name field, enter Meridien Restaurant Guide.

A screenshot shows "Meridian Restaurant Guide" entered in the Name field of General tab of AIR Settings dialog box.

This will be the name of your published application.

6. From the Window Style menu, choose Custom Chrome (Transparent).

A screenshot shows "Custom Chrome (Transparent)" selected from the Windows Style menu in General tab of AIR Settings dialog box. The other two options displayed in the menu are "System Chrome" and "Custom Chrome (opaque)".

Custom Chrome (Transparent) creates an application without any interface or frame elements (known as chrome), and with a transparent background.

7. Click the Signature tab at the top of the AIR Settings dialog box.

A screenshot shows the contents of the Signature tab in AIR Settings dialog box.

Creating an AIR application requires a certificate so that users can identify and trust the developer of the Animate content. For this lesson, you won’t need an official certificate, so you can create your own self-signed certificate.

8. Click the Create/New button next to Certificate.

9. Enter your information in the empty fields. You can use Meridien Press for Publisher Name, Digital for Organization Unit, and Interactive for Organization Name. Enter your own password in both password fields, and then enter meridienpress.p12 in the Save As field. Click the Folder/Browse button to save it in a folder of your choice. Click OK.

A screenshot shows the new Certificate page with user entered details.

Animate creates a self-signed certificate (.p12) file on your computer.

A screenshot shows the confirmation message by Adobe Animate, informing that the "Self-signed certificate has been created".

Animate automatically fills out the path to your .p12 file in the Certificate field. Make sure that the Password field is filled (the password must match the one you used to create the certificate), and that Remember Password For This Session and Timestamp are selected.

A screenshot shows the fields automatically filled up in the Signature tab of AIR Settings dialog box.

10. Now click the Icons tab at the top of the AIR Settings dialog box.

A screenshot shows the following options displayed in the "Icons" tab of AIR settings dialog box: icon 16X16 icon 32X32 icon 48X48 icon 128X128

11. Select icon 128x128, and click the folder icon.

12. Navigate to the AppIconsForPublish folder inside the 10Start folder, select the restaurantguide.png file provided for you, and click Open.

A screenshot shows the icon selections in the AIR Settings dialog box.

The image in the restaurantguide.png file will be the application icon on the desktop.

13. Click the Advanced tab at the top of the AIR Settings dialog box.

14. Under Initial Window Settings, enter 0 for the X field and 50 for the Y field.

A screenshot shows the X and Y coordinates set under Advanced tab of the AIR Settings dialog box.

When the application launches, it will appear flush to the left side of the screen and 50 pixels from the top.

15. Click Publish and then click OK.

Animate creates an AIR installer (.air).

A screenshot shows the icon for ".air" installer created by Animate in the path "10Start.restaurantguide.air".

Installing an AIR application

The AIR installer is platform-independent, but it requires that the AIR runtime be installed on the user’s system.

A screenshot shows the Application install dialog box displayed when the user clicks on the AIR installer.

1. Double-click the AIR installer that you just created, 10Start_restaurantguide.air.

The Adobe AIR Application Installer opens and asks to install the application. Since you used a self-signed certificate to create the AIR installer, Adobe warns of a potential security risk due to an unknown and untrusted developer. (Since you can trust yourself, you’re safe to proceed.)

2. Click Install, and then click Continue to proceed with the installation at the default settings.

The application called Meridien Restaurant Guide is installed on your computer and automatically opens.

A screenshot shows the opening page of the "Meridien Restaurant guide" application.

Notice that the application is positioned at the far left edge of your desktop, 50 pixels (between one-quarter and one-half inch, depending on the resolution of your display) down from the top edge, as you specified in the AIR Settings dialog box. Note, too, that the Stage is transparent so your graphic elements float over the desktop, much like the appearance of other applications.

3. Exit/Quit the application by pressing Alt+F4/Command+Q.

Creating a projector

In some cases—for example, if you don’t want to deal with an app that requires installation and all the accompanying security issues—you may want to use a low-tech and simpler distribution method. A projector is a self-contained file that includes the Flash Player runtime so your audience can simply double-click the projector icon to play and view your multimedia content.

You can publish either a Macintosh or Windows projector from an ActionScript 3.0 or AIR document. However, unlike when you’re creating an AIR application, with a projector you don’t have publishing options such as choosing thumbnails for the app icon, or specifying a transparent background or initial position when the app is launched.

1. Open 10Start_restaurantguide.fla.

2. Choose Commands > Export As Projector.

The Publish Settings dialog box opens.

A screenshot shows the "Publish Settings" dialog box in which "Mac Projector" and "Win Projector" options are selected under Other formats in the left panel.

3. Under Other Formats in the left column, select Mac Projector and/or Win Projector. Windows projectors have the file extension .exe and Mac projectors have the file extension .app.

4. Specify the filename and location where you want Animate to save the projector. Each projector (Mac and Windows) needs a unique filename, so highlight each option to enter it.

5. Click Publish.

Animate creates the selected projector or projectors in the output location, with a filename that matches the Animate filename. Click OK.

6. Double-click the projector file.

A screenshot shows the "Meridien Restaurant Guide" application open as a separate file on the Desktop. The application displays the "Main Menu" button on top of the background image. Four thumbnail boxes display the various options available.

The restaurant guide opens as a separate application on your desktop. Compare your projector application with your AIR application.


Image Note

Any dependent assets, such as video files, must also be included with your projector to play correctly. Animate does not embed those dependent files into the projector.


Publishing to Mobile Devices

You can also publish Animate content to mobile devices running on Google Android or on Apple’s iOS, such as the iPhone or iPad. To publish Animate content to a mobile device, you target AIR for Android or AIR for iOS to create an application that viewers download and install on their devices.

Testing a mobile app

Creating an app for mobile devices is more complicated than creating an application for the desktop, because you have to obtain specific certificates for development and distribution. For example, Apple requires that you pay a yearly subscription to be a certified developer to upload apps to the iTunes Store. Developing for an Android device requires a one-time fee. Moreover, you have to factor in the additional time and effort required for testing and debugging on a separate device. However, Animate CC provides several ways to facilitate testing content for mobile devices:


Image Note

The iOS Simulator is part of Apple’s Xcode developer toolset available as a free download from Apple.



Image Note

Testing an app on an iOS device requires that you be part of Apple’s iOS Developer program, where you create development, distribution, and provisioning certificates. The certificates allow you to install apps on iOS devices for testing and upload apps to the iTunes store.


You can use the mobile device simulator provided with Animate, the AIR Debug Launcher, to test mobile interactions. The SimController that accompanies the AIR Debug Launcher emulates specific interactions such as tilting the device (using the accelerometer), touch gestures such as swiping and pinching, or even using the geolocation functions.

For iOS devices, Animate can publish an AIR app to test in the native iOS Simulator, which emulates the mobile app experience on your Mac OS desktop.

Connect a mobile device to your computer with a USB cable and Animate can publish an AIR app directly to your mobile device.

Simulating a mobile app

You’ll use the Adobe SimController and AIR Debug Launcher to simulate mobile device interactions within Animate Professional CC.


Image Note

On Windows, a security warning may appear when you use the AIR Debug Launcher. Click Allow Access to continue.


1. Open 10Start_mobileapp.fla.

A screenshot shows the title page of "Meridien X-Challenge" mobile app.

The project is a simple application with four keyframes that announces an imaginary sports challenge set in our familiar city of Meridien.

The project already contains ActionScript that enables the viewer to swipe the Stage left or right to go to the next or previous frames.

Examine the code in the Actions panel. The code was added from the Code Snippets panel, which includes dozens of code snippets for interactivity on mobile devices.

A screenshot show the code for the mobile app in the Actions panel.

2. In the Properties panel, notice that the target is set for AIR 23.0 for Android.

3. Choose Control > Test Movie > In AIR Debug Launcher (Mobile), which should already be checked.

A screenshot shows the option "In AIR Debug Launcher (Mobile)" option selected under the menu option, "Control > Test Movie".

The project publishes to a new window. In addition, the SimController application launches, which provides options for interacting with the Animate content.

A screenshot shows the mobile app launched along with the Sim controller application.

4. In the Simulator panel, click Touch And Gesture to expand that section.

5. Select Touch Layer.

The simulator overlays a transparent gray box on the Animate content to simulate the touch surface of the mobile device.

6. Choose Gesture > Swipe.

A screenshot shows two selections in the Touch and Gesture section of the Simulator.

The simulator is now enabled to emulate a swipe interaction. The instructions at the bottom of the panel detail how you can create the interaction with just your mouse cursor.

7. Press on the touch layer over your Animate content, drag to the left, and then let go of your mouse button.


Image Tip

You can change the opacity of the touch layer by changing the Alpha value.



Image Note

Don’t move the window that contains your Animate content (AIR Debug Launcher, or ADL) when you’ve enabled the touch layer. If you do, the touch layer won’t align with the ADL window, and you won’t be able to accurately test your mobile interactions.


The yellow dot represents the contact point on the touch layer of the mobile device.

A screenshot shows the homepage of the zip line plunge option in the Meridien X challenge game.

The project recognizes the swipe interaction, and the second keyframe appears.

8. Swipe left and right.

Animate advances ahead one frame, or moves back one frame.

9. Close the window.

Publishing a mobile app

Lastly, you’ll examine the settings in Animate to publish a mobile app for iOS. Publishing an app for Android has similar settings.

Although it’s beyond the scope of this lesson to present the steps in detail, you’ll see the required certificates, assets, and configurations to properly publish and distribute an app through the iTunes store.

1. In Animate, choose File > New, select AIR for iOS for Type, and click OK.

A screenshot displays the Animate settings to publish the mobile app for iOS.

Animate creates a new Animate file, configured for iOS. The Stage size is set at 640 × 960, and the target is set to AIR 23.0 for iOS.

2. Click the wrench icon next to the Target menu.

The AIR For iOS Settings dialog box appears.

3. Click the General tab.

A screenshot shows the General selections and entries in the AIR for iOS Settings dialog box.

The General tab contains information about the output files and general settings. The actual published file has the extension .ipa. You can choose different aspect ratios (landscape or portrait), and target specific devices (iPhone and/or iPad) and resolutions. The iOS Simulator SDK field is the path to the iOS Simulator file used for testing (Control > Test Movie > On iOS Simulator). The Included Files list contains the two required files (a SWF and an XML file), but you can add additional dependent media files if required for your project. For iOS apps, you can also include a PNG file with a specific filename as the default launch image—for example, [email protected]—that appears as soon as an app loads.

4. Click the Deployment tab.

A screenshot shows the Deployment selections and entries in the AIR for iOS Settings dialog box.

The Deployment tab contains information for testing and distribution. The Certificate and Provisioning Profile fields specify the names of required documents that you create as a certified Apple Developer. They certify you as a known and trusted developer so Apple and your potential customers can purchase and download your app with confidence.

The iOS Deployment Type menu lists the various ways you may publish your app, such as testing on a connected USB device, testing on a variety of devices (ad hoc), or for final distribution to the iTunes store. Each phase of development requires different certificates and a new round of publishing.

5. Click the Icons tab.

A screenshot shows the Icon options available in the AIR for iOS Settings dialog box.

The Icons tab lists the dimensions available for the icons that will identify your app on each mobile device. You must provide icons in a range of resolutions depending on the device you target Select a dimension and click the folder icon to navigate to the graphics file to use for each icon.

6. Click the Languages tab.

A screenshot shows the Language options available in the AIR for iOS Settings dialog box.

The Languages tab lists the different languages available for your app to support. Select the check box in the Enable column next to a language to support it in your app.


Image Note

For more information about publishing Animate content to AIR for iOS or Android, visit the Adobe AIR Developer Center at www.adobe.com/devnet/air.html. Tutorials, tricks and tips, and sample files are available for download.


Next Steps

Congratulations! You’ve made it through the last lesson. By now you’ve seen how Adobe Animate CC, in the right creative hands (yours!), has all the features you need to produce media-rich, interactive projects and animations that publish to multiple platforms. You’ve completed these lessons—many of them from scratch—so you understand how the various tools, panels, and code work together for real-world applications.

But there’s always more to learn. Continue practicing your Animate skills by creating your own animation or interactive site. Get inspired by seeking out animation and multimedia projects on the web and exploring apps on mobile devices. Expand your Animate knowledge by exploring the Adobe Animate Help resources and other fine Adobe Press publications.

Review Questions

1. What’s the difference between author-time and runtime?

2. What files do you need to upload to a server to ensure your final Animate movie plays in the Flash Player in web browsers?

3. How can you tell which version of Flash Player a viewer has installed?

4. What is CreateJS?

5. Why is it recommended that animations built in HTML5 Canvas use classic tweens?

6. How do you incorporate interactivity in an HTML5 Canvas document?

7. What is the difference between the way ActionScript and CreateJS JavaScript handle frame numbers on the Animate Timeline?

8. What are the various ways you can test a Animate file for a mobile device?

9. What is a code-signing certificate, and why do you need one for an AIR application?

Review Answers

1. Author-time refers to the environment in which you build your Animate content, such as Animate Professional CC. Runtime refers to the environment in which your Animate content plays back for your audience. The runtime for your content can be the Flash Player in a desktop browser or an AIR application on the desktop or on a mobile device.

2. To ensure that your movie plays as expected in web browsers, upload the Animate SWF file and the HTML document that tells the browser how to display the SWF file. You also need to upload the swfobject.js file, if one was published, and any files your SWF file references, such as video or other SWF files; be sure that they are in the same relative location (usually the same folder as the final SWF file) as they were on your hard drive.

3. Select Detect Animate Version in the HTML tab in the Publish Settings dialog box to automatically detect the version of Flash Player on a viewer’s computer.

4. CreateJS is a suite of open source JavaScript libraries: EaselJS, TweenJS, SoundJS, and PreloadJS. When you publish or test an HTML5 Canvas document, Animate uses CreateJS to generate all the necessary JavaScript code to represent your images, graphics, symbols, animations, and sounds on the Stage. It also outputs dependent assets, such as images and sounds.

5. Although an HTML5 Canvas document supports all motion tweens and shape tweens, they are exported as frame-by-frame animations, and can increase the file size of your exported JavaScript code. Use classic tweens, which are retained as runtime tweens that conserve file size and allow you to control the animation dynamically via JavaScript.

6. Insert JavaScript on a Animate Timeline by writing code directly into the Actions panel. If you’re new to JavaScript, you can use the HTML5 Canvas Code Snippets panel, which provides JavaScript snippets for common interactions, such as mouse clicks and Timeline control.

7. In the JavaScript for CreateJS, frame numbers begin at 0. In Animate, frame numbers begin at 1. For this reason, frame labels should be used so you can avoid references to frame numbers.

8. You can test your Animate project for a mobile device by testing it in the Air Debug Launcher (Control > Test Movie > In AIR Debug Launcher [Mobile]). The accompanying SimController allows you to simulate various mobile interactions, such as pinches and swipes. You can also test your Animate project by publishing it directly to a connected USB device (Android or iOS). Lastly, you can test an iOS app in the native iOS Simulator (Control > Test Movie > On iOS Simulator).

9. A code-signing certificate is a certified document that acts as your digital signature. You purchase one from a certification authority. It provides a way for your audience to authenticate your identity so they can confidently download and install desktop AIR applications, or AIR apps for Android or iOS.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.64.66