In the previous chapter, we explored content creation using the various tools within Animate and focused on animating that content through the use of both Shape Tweens and Classic Tweens.
In this chapter, we are going to design animated content for publication to the native web using the HTML5 Canvas target platform. As we build out a digital advertisement, we will include externally created content such as photographic bitmap images, design text objects within the project using Adobe Fonts, and animate both by focusing on the third tweening type available to us in Animate: the motion tween. We'll close out this chapter by examining various properties unique to motion tweens and then explore a few ways of writing code to make our project interactive.
After reading this chapter, you'll be able to perform the following functions in Animate:
You will need the following software and hardware to complete this chapter:
The code in action video for this chapter can be found here: https://bit.ly/3qLL7FM
While we talked in some detail about different document types and publishing platforms in Chapter 2, Exploring Platform-Specific Considerations, and Chapter 4, Publishing and Exporting Creative Content, we haven't focused on any particular platform when creating and animating content. This chapter will change that as we will be focusing on the native web in everything we do.
The first step in designing content for the web, such as digital advertisements or interactive infographics, is to create a document that targets these technologies and gets our assets together.
We'll first create a new document that targets native web technologies from the various presets available to us in Adobe Animate. The New Document dialog includes a series of categories containing focused sets of presets to be used. You can access this dialog by choosing File | New or by clicking the Create New button on the welcome screen.
Whichever method you choose, the New Document dialog will appear:
With the New Document dialog open, we are ready to choose a preset. Along the top, you'll find six categories: Character Animation, Social, Game, Education, Ads, Web, and Advanced. We've already had a look at the Advanced category earlier in this book and will now turn our attention to how the others function.
We are designing a motion advertisement that will be supported on the native web:
With that, our new document has been configured, saved, and ready to be worked on:
A quick look at the Properties panel should confirm that all of the choices we've made regarding width, height, FPS, and the target platform have been preserved.
Before moving on, we should note a couple of important things about digital advertising on the web and the standard presets we have based our new document on. If you are new to the field of digital advertising, you may not know there is a set of common ad sizes that almost all ad delivery networks accept.
These range from elongated banners, tall skyscrapers, and a set of sizes that are squarer in aspect. These can be seen in the following diagram:
Some of these sizes should be instantly recognizable by shape alone as they appear all over the internet, on news websites, social networks, and personal blogs – everywhere. The presets within the Ads category in Animate are all based on these standard sizes.
Tip
An extensive list of digital advertising sizes is maintained by Google and can be found at https://support.google.com/google-ads/answer/7031480.
With our new document created and saved, let's turn our attention to the content to be included in our advertisement.
Up to this point, we've only worked with assets that have been created within Animate itself and haven't used anything external to the software. Many advertisements contain bitmap images such as .jpg and .png files for a photorealistic approach. Animate has no problem using bitmap images within any project, but you must import the files to be used into the project library.
We've prepared a set of photographic images that have been prepared using Adobe Photoshop that will be used in different ways within this project. Our example advertisement is going to be for a unique brand of coffee that can only be purchased online.
Note
You can find the images we have used here within the exercise files at https://github.com/PacktPublishing/Adobe-Animate-2022-for-Creative-Professionals-Second-Edition.
Let's go ahead and import some bitmap images into our document:
Alternatively, we could have chosen to import our images directly onto the stage. When choosing Import to Stage… from the Import menu, your files will be imported into the project library, just as we've done here, but instances of these bitmaps will also be placed on the stage. We are going to handle that part ourselves.
We only want to bring an instance of CoffeeBeans.jpg onto the stage at this point, so we can ignore Bean.png for now:
The image is too large for the stage at its native size is 1,000 pixels in width!
This will center the bitmap instance across the stage. The image will overlap the stage on the pasteboard, as well as on all sides, but that is what we want.
We now have an instance of the CoffeeBeans.jpg bitmap file on the stage, resized to allow just a bit to bleed over onto the pasteboard. All of this is contained in a single layer named CoffeeBeans, which consists of a single frame.
Next, we'll go ahead and create more objects that will make up the rest of our digital advertisement.
This chapter marks our first time using imported bitmap files in a project, but that won't be our only first. We need some text to include within the coffee advertisement as well and for that, we will put the Text tool to work.
Once the text is in place, we will add additional elements to complete the layout portion of this project:
We will want to use Static Text for this task, so be sure that the Instance Behavior dropdown is set to this. Static Text is rendered to shape data upon being published, ensuring that even viewers who do not have a specific font installed can see the text using the intended font. We'll look at Dynamic Text as part of Chapter 11, Developing Web-Based Games.
I've selected an Adobe Font for this project called Neue Haas Grotesk Display Pro, which can be used by anyone with an Adobe Creative Cloud subscription – just visit https://fonts.adobe.com and search for it!
I'm going to use a 48pt value for Size and #FF9900 for my Fill color.
To add text to the stage, you can click and begin typing to create an expanding width Point Text object or click and drag a textbox with a specific width to create a Paragraph Text. We want to control the width of our text objects, so we will create Paragraph Text:
The advertisement layout is beginning to take shape! One of the biggest concerns right now is the legibility of the text across the background image. We can increase the readability of the text message by adding a shape between the text and background.
That looks pretty good! The initial layout for our advertisement is now complete.
With our text objects and the background bitmap image on their layers, this gives us a good starting point to create some animation.
In this section, we assembled imported external bitmap images and created text objects within a new document targeting the native web. Next, we'll begin animating this content by using a tween type called Motion Tween – a tween we haven't encountered yet in this book.
Now, let's add motion to the various components of our advertisement. In the previous chapter, we used both shape tweens and classic tweens to create motion, depending on whether our object was a shape or a more complex symbol instance. In this project, we have a bitmap image instance to animate, along with a group of text and shape objects.
We could convert these various objects into symbols and employ a Classic Tween – that would work just fine! However, this is the perfect opportunity to introduce the third type of tween that you can use within Animate – Motion Tween.
Motion tweens work very similarly to classic tweens in that they are both used to animate symbol instances and not shapes. A lot differs between the two as well – both in how they are created and the various properties available to us.
Note
Classic tweens used to be called motion tweens before motion tweens were introduced to Flash Professional. When that happened, they were given the "classic" moniker and are now known as classic tweens.
We'll have a look at all of this, but the first task in preparing to use a Motion Tween is to ensure anything we want to animate is encapsulated within a symbol.
Before animating with motion tweens, we will transform the contents of both our existing layers into symbols to tween their instances:
Have a look in the Library panel and note that the newly created symbol appears there – right alongside the images that have been imported. Both imported files and symbols created in Animate will become part of the project library and you can use as many instances of each as you like.
We now have a single Movie Clip symbol instance within each of our layers and they can each be effectively tweened in this state. The CoffeeBeans symbol contains a single bitmap image, while the TextMessage symbol contains multiple objects within it, but we can manipulate them all since they are now part of a single Movie Clip symbol.
Now, let's create a Motion Tween within each layer to add animation across both symbol instances:
The Create Motion Tween command establishes a Motion Tween with only a single manual keyframe created. This is very different from shape tweens and Classic Tweens, which both require at least two keyframes to create a tween. This action converts the chosen layer into a special Motion Layer and 1 second's worth of frames is added.
Note that these keyframes in the motion tweens appear as small diamonds and not the circular keyframes we are used to:
In addition, you do not even have to set a keyframe manually, as we have done here. All you need to do is change any of the supported properties with the playhead at a specific frame; a keyframe representing the change in data will appear automatically. Again, this is quite different from the other tween types as a Shape Tween or a Classic Tween only behaves this way when the Auto-Keyframe option is enabled.
The original scale is preserved in the previously inserted keyframe at frame 30 and a new scale value is present at frame 1. Since we are working with motion tweens, only the scale values are contained within these keyframes. This is because that is the only property that has been changed.
Note
Motion tweens can have specific properties such as scale, position, rotation, and more contained in discrete keyframes, which makes motion tweens very versatile!
Notice that the animation loops endlessly and that there is no pause option at the beginning or end. We will remedy these aspects of our animation before closing out the project.
With two pieces of content animated, we have seen that changing position when using a Motion Tween results in a Motion Guide on the stage. We'll give this a better look and put it into play with another animated object in the next section.
To include additional library items, follow these steps:
With the new asset in place on its own layer, let's make some adjustments to the previously included animated content.
At this point, we are going to want to adjust the previous animations a bit to allow some padding both before and after the animations. As a common practice in character animation, it's always a good idea to include a bit of anticipation this way, even with motion graphics in advertising.
So, let's fill out our timeline a bit more and perform some additional keyframe arrangements:
The previous scaling animation is preserved but takes up double the time now.
Play the animation using the controls above the timeline to view the effect of anticipation.
With these adjustments in place, we can animate the Bean symbol instance in the proper context.
It's time to add motion to the Bean symbol instance! Right now, it exists at frame 30 and just sits there. We will have the bean drop in from the top right and settle to its present location in the lower left:
Notice that, since the position of our object differs between the two keyframes, a Motion Guide automatically appears between the two positions. This is very different from working with a Classic Motion Guide since we don't have to do anything special to make it appear.
Each frame in our tween is represented by a small dot along the Motion Guide path. This is a great way to visualize easing for the position in our motion tweens.
Certain aspects of a Motion Tween are very different from the two other tween types in Animate, but in terms of execution, they perform in mostly the same way.
Next, we'll examine the properties associated with a Motion Tween.
Just as with shape tweens and classic tweens, Motion Tween properties can be accessed through the Tweening section of the Properties panel:
There isn't a lot here by comparison. That is due to the fact that additional properties are located elsewhere. We'll look into that next, but first, the obvious properties:
You may have noticed from our initial exploration of Motion Tween properties that there are no Ease Effect presets like there are in the Shape Tween and Classic Tween properties. With a Motion Tween, you access similar functionality through the Motion Editor area.
The Motion Tween ease presets are somewhat similar to what can be found in other tween types, but they differ in some ways as well. Double-click on a preset to apply it to any selected property. In addition, certain presets can also have their intensity values adjusted.
Once you apply an ease preset, the apparent ease will be reflected in the easing graph by way of a dashed easing curve alongside the original curve.
To hide the Motion Editor area, simply double-click on the associated Motion Tween in the same way that you opened it.
As we saw when we looked at the Shape Tween and Classic Tween properties, motion tweens have their own set to be aware of. In the next section, we'll learn how to make our advertisement interactive using JavaScript code.
In this section, we constructed symbols to animate our text objects and bitmap images. We then brought additional items from the project library onto the stage and prepared the timeline for animating with motion tweens. Taking full advantage of the Motion Tween properties, we animated using property adjustments, motion guides, and the advanced Motion Editor to complete our motion advertisement. Next, we'll finish everything off by including a bit of interactivity by using JavaScript.
Generally, a digital advertisement like the one we've designed here will need to be interactive as well. Most ads of this kind will respond to user interaction by opening a web page where the user can get more information about, or even purchase, the advertised product or service.
Since we are publishing to the native web using an HTML5 Canvas document type, we will be coding our interactions with the JavaScript language.
Animate is a unique piece of software in that it allows both design and development within the same application. This hybrid approach has always been a strong part of the tool and continues to be so, no matter which platform you might be targeting.
Let's go ahead and add some code to our motion advertisement:
If you know what code to write, you can just start writing directly into the Script Editor area here. If you need a more guided approach, we'll tackle that momentarily.
Note
The this keyword refers to the current timeline. We are telling the playhead in the current timeline to stop() as soon as it reaches the current frame.
We want the user to be able to click on our little coffee bean symbol instance to be taken to a website. To make a Movie Clip symbol instance interactive, it must be given an Instance Name so that the code can identify and address it.
The resulting JavaScript code that's been created by the Actions Wizard area is included here:
var _this = this;
_this.coffeebean.on('click', function(){
window.open('https://josephlabrecque.com', '_blank');
});
The code is defining a variable, this, to preserve scope, followed by registering an event listener on our coffeebean object. If a click event is detected, the function to open a URL in the web browser is executed. Passing in the '_blank' argument opens the URL in a new window or tab. Pretty simple stuff!
In this snippet of code, all the comments have been removed for clarity.
Note
We will be looking at a lot more JavaScript in Chapter 11, Developing Web-Based Games, and Chapter 12, Producing Virtual Reality Content for WebGL.
In this section, we had a look at the features of the Actions panel and used both the Script Editor area and the Actions Wizard area to add interactivity to our digital advertisement.
In this chapter, we focused on creating a web-based digital advertisement using the HTML5 Canvas document type and introduced several new topics while doing so. We learned how to import bitmap images, create text objects, convert object types into symbols, and animate those symbol instances by using motion tweens. Building on that, we also had our first look at the Actions panel and made our content interactive.
In the next chapter, we will have a look at an even newer way of animating content in Animate by using Layer Parenting.