Chapter 3. Creating Advanced Animations

When building animations it’s important that you don’t introduce things into your animations that don’t export. The last thing you want to do is to spend several hours tweaking an animation that previews in Flash, only to discover that Wallaby doesn’t support some aspect of it.

As I mentioned before, Wallaby can’t possibly support all of the many features of Flash. Here is a list of what it does support, along with some usage tips:

Timeline

Wallaby supports the Flash Timeline, keyframes, and tweens. Support for nested timelines (movie clips) does exist, although it’s suggested that animations should be designed primarily on Flash’s main Timeline where possible.

Layers

Standard layers, guide layers, and mask layers are supported within animations.

Wallaby only supports masks with a duration that lasts the duration of the frame. If you make a partial mask on a layer, it will generate an error. Masks, when converted, can also put significant strain on less powerful devices. As such, be careful when using complicated masking, and be sure to keep the number of masks in your animation at a minimum.

ActionScript

Wallaby provides no support for any ActionScript, with one exception: the stop() command. Putting stop() on the final frame of an animation allows you to specify that the animation should not loop. Otherwise, all animations will loop by default.

Symbols

Symbols and symbol identifiers are supported in Wallaby. In fact, symbol identifiers are carried through to resultant HTML5 code, making it much easier to implement interactivity to individual parts of your animation using JavaScript after the fact. We’ll touch on this in the “Adding Basic Interactivity” section of Chapter 5.

Filters

Alpha filters are the only filters currently supported by Wallaby.

Shapes

In general, any vector graphics you can create in Flash can be converted in Wallaby. This includes all shape tools, and the pen and pencil tools.

Strokes

Wallaby supports strokes of any size. Stroke styles, on the other hand, are limited to hairline, solid, and dashed.

Fills

Wallaby supports gradient-based fills, image-based fills, and solid colors.

Images

Wallaby supports any images that can be imported into Flash. Image transparency is also supported, but this will depend largely on the transparency support in the browser where the animation is being viewed.

Buttons

Buttons with normal, hover, and active states can be designed using Flash and exported with Wallaby. When exported and viewed in a browser these buttons will change their states per the user’s interaction. However, since there is no ActionScript support within Wallaby, any button-click actions, such as navigating to a new page, will need to be added after the export using JavaScript.

Paths

Motion paths can be used in order to animate your visual assets along a path.

Text

Wallaby provides support for standard text and some TLF text. When using TLF text, make sure you do a few text exports early on to ensure that your text content is supported.

Tweens

Wallaby supports classic tweens, motion tweens, and shape tweens.

Build your animation with these supported features, and come conversion time, you should have few issues. After you’ve exported, the next step will be to ensure that the animation performs well in the browser.

Building for Performance

Before you start creating that complex animation that is going to blow everyone away, it’s important to understand a bit about performance tuning. As with any project, working fast and seeing fast results can be exciting, but if you aren’t diligent in organizing your project and trimming the fat as you add complexity, the performance of the final product will really suffer.

In our case, there is a reason why performance tuning is especially important. If you’ve ever worked with visual tools for creating web content or visual tools that export any kind of programmatic code, you may have noticed that the tools fail to be telepathic. By this I mean that while these tools do their best to translate what you do into code, they can’t know exactly how you intend to use any of the code, and therefore the code they generate can be somewhat generic and/or poorly structured. Effectively, this means the generated code, although functional, rarely performs as well as something that was handwritten and optimized for the task. Wallaby isn’t exempt from this rule, and while it will work fine for the creation of most animations, those of you who are making exceptionally complicated animations may encounter some poor performance from Wallaby that you wouldn’t experience if the same animation were generated by some handwritten JavaScript optimized for the task. It’s likely that performance won’t be an issue for most of the animations you will export, but if you’re attempting something complicated there are some things to keep in mind to ensure that your resultant animation can perform as well as possible.

When we use Wallaby we’re really asking one technology (Flash) to create content for a completely different technology (HTML5). With this kind of approach there are challenges due to the large delta between how those technologies handle things.

Consequently, not everything that runs well in Flash Player runs well in a browser.

I’m not simply referring to unsupported features of Flash that cannot be translated to HTML5, but rather to the performance of your successfully exported animation. That being said, when building more complicated animations you’ll want to pay close attention to optimizing your project so that the final product will run smoothly.

Here are a few guidelines to accomplish this.

Export and Test Often

I can’t stress how important this is if you’re attempting a more complicated animation. You want to avoid the situation where you’ve spent several days building an animation, only to discover at the 11th hour that it doesn’t run well in a browser. At that stage of the game, you’ll have a very difficult time determining the point at which things became too complicated or what you should do to attempt to fix the performance issues.

If instead you export frequently after making significant changes, you’ll be less likely to waste days building a bad animation and you’ll be able to identify and resolve issues before it’s too late.

Take the Right Approach

Let’s imagine that you want to make an animation with falling snow and you want each snowflake to have some variation.

One approach could be to make 50 different snowflakes, each as a highly detailed transparent image. You could then import them, scale them each to a different size, and animate them individually so that they fall and rotate at the same time.

While this might create a realistic-looking snowfall effect, it does so in a way that creates a lot of strain on the browser. Each snowflake has to be held separately in memory, and then each one must be translated during each step of the animation.

Another approach that could accomplish something very similar is to create one large image with snowflakes of different designs, sizes, and rotations, and simply animate it so that it moves downward, thus creating the illusion of falling snow. This approach requires much less effort on behalf of the browser and would allow you to create several additional animated elements in your animation before reaching its performance limitations.

Stay Mindful of Bandwidth

If you’ve developed anything for the Web in the past, you know the value of maintaining a low kilobyte weight to ensure fast load times. Wallaby exports your assets in the same form that you include them in your project and makes no effort to appropriately size or compress them beyond what you have prepared. Make sure you apply the same care and consideration to preparing and handling the assets for animation as you would for anything else. For example, you would want to avoid including needlessly large or uncompressed images if the way in which you are using those images doesn’t necessitate such a high quality.

Determine the Limitations

Naturally the browsers and devices that your audience is using aren’t all created equally.

Here’s an example. Safari, unlike Chrome, supports GPU acceleration, giving it some advantage in rendering some more complex animations on devices equipped with a powerful GPU such as an iPad or iPhone. On the other hand, the optimizations of the V8 JavaScript engine within Chrome coupled with the more powerful CPUs found in desktops and newer tablets offer some advantage as well.

The trick, however, is not to determine the browser and device combination that will run your animation the fastest, but rather to determine the slowest browser and device combination that you wish to support. You’ll need to draw a line as to the minimum hardware and browsers that you expect to support, and this is how you can determine how complicated your animation can be and how much effort you’ll need to put into tuning its performance.

If, on the other hand, you only intend to target a specific device and browser combination, you’re free to create animations that leverage the full potential of each.

Wallaby-Specific Performance Tips

There are a few features that run great in Flash but, when converted to HTML5, require a lot of JavaScript code to pull off. As a rule, the more complex the generated code, the more the browser has to work, which can result in poor animation performance. With that being said, here are just a few Wallaby-specific performance tips to help you create lightweight and well-performing animations:

Use motion tweens

In Wallaby, motion tweens can be converted to HTML5 in a far more efficient fashion than frame-by-frame animations. Avoid using the latter altogether if possible, and focus on using tweens to create animations.

Minimize shape tweens

Shape tweens, although supported, can result in a lot of generated JavaScript and can place some strain on the browser. Use them sparingly in order to ensure that your animation performs well.

Use simple paths

Motion paths are typically OK, but try to avoid using exceptionally complex paths as they can have a negative effect on performance.

Now that we’ve greatly raised the chances of building a supported and well-performing animation for conversion, let’s take a closer look at the Wallaby interface and the process of conversion.

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

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