Skip to main content

Video: Creating a Reusable Animation Library

Creating a Reusable Flash Animation Library, the next episode in the gripping and suspenseful series CodeDependent, is now available from Adobe TV.


This episode is a bit of a departure from my normal shows. Usually, I show graphics and animation techniques in Flex and Flex 4. This time, I talk about Flash Pro, the authoring tool for Flash (not Flex) applications. In particular, I show how to create a reusable library in Flash Pro that you can then link to and use in other Flash Pro projects. The process of creating a library in Flash Pro wasn't obvious to me, so I thought it might be useful to show how it was done. Thanks to Trevor McCauley for helping me figure this out. Trevor's on the Flash player team and is very helpful is figuring out all kinds of things about how Flash works, including this bit about Flash authoring. Check out his blog at senocular.com.


Here's how this relates to Flex and my work for Flex: the library I create is an animation library based on the core facilities underlying the Flex effects. I call the library Flexy.


Flex effects are pretty dependent on the Flex library overall. They use concepts in UIComponent, graphic elements, styles, and other concepts that are found in the core Flex framework. So building a full-on Flex effects library in Flash Pro would necessarily drag in so much of the Flex infrastructure that it wouldn't be worth the effort; you might as well just use Flex directly.


But the underlying animation engine that the new Flex 4 effects depend on, including the Animation class, arbitrary type interpolation, and the new easer interface and classes, are independent of Flex effects and of nearly everything else in Flex. I wanted to see if I could break those animation facilities out into a separable library. There were various niggling dependencies, such as the use of the EffectEvent class, some use of resource bundles for error strings, and other minor issues, but one 50-minute train commute later, I had a 13k library built in Flash Pro that had no Flex dependencies and had all of the underlying animation support that the Flex effects use for running their animations.


Flexy doesn't handle all of the effects functionality, of course, because Flex effects aren't part of the port. Flex effects provide mainly two extra layers of support for animations. First, they handle setting animated values on target objects/properties. The animation infrastructure only handles calculating the animated values, not what to do with those values. Second, effects have extra built-in logic and convenience APIs that makes it easier to declare and run effects than you might otherwise have to do with a more manual approach to animation.


I can't do much about the second bit; that's most of the code in effects, and I was looking for something simple. But for the first part, I've provided a utility class called PropertyAnimator which you can use to automate assigning animated values to properties, just like effects do. It simplifies using Animation and makes very easy property animation possible with this library.


Check out Flexy and see what you can do with it. And come back for the next show to see a simple example of using the library from within Flash Pro.


Here's the video:





There is no demo application this time, because the demo is really just the reusable Flexy library, which isn't very exciting to watch, as demos go, because it just sits there, being reusable.


Here is the demo code. This is a zip file containing the Flash Pro project (Flexy.fla), the Flexy library itself (Flexy.swc), and the source code that Flexy was built with.


Users of the Flex Animation class should be able to start playing with the library pretty easily, but if the API is a bit of a mystery to you, check back for my next show, in which I'll dmeonstrate how to use the library in Flash Pro for a simple example.


Here's where you can find CodeDependent on iTunes.


And here's where you can find CodeDependent on YouTube.


Enjoy.

Comments

Popular posts from this blog

Austerity-A Fancy Word for Destitute.

The reason for this post is not for the folks who have been caught in the first wave of personal economic hard reality, but the next wave. Regardless of the optimism espoused by grinning leaders and sycophant press, we are entering the final stage of global economic collapse. It began in 2008 and was forestalled for five years with fudge putty, but the weight of global indebtedness cannot be propped any longer and the final crunch is imminent. Austerity measures herald the final throes.  Indications of coming austerity.   Austerity measures are the final last ditch effort, futile or not! Back in the day many of us old-timers went through periods of "hard-times". In retrospect I realize there is no comparison to yesteryear hard times and today's version. Back then, expectations were never very high for the working class, there were no sophisticated systems or conveniences anyway. In fact the difference between being "set" or not was about having treats or not. Si...

Terrifying Arctic methane levels

A peak methane level of 3026 ppb was recorded by the MetOp-B satellite at 469 mb on December 11, 2021 am. This follows a peak methane level of  3644 ppb  recorded by the MetOp-B satellite at 367 mb on November 21, 2021, pm. A peak methane level of 2716 ppb was recorded by the MetOp-B satellite at 586 mb on December 11, 2021, pm, as above image shows. This image is possibly even more terrifying than the image at the top, as above image shows that at 586 mb, i.e. much closer to sea level, almost all methane shows up over sea, rather than over land, supporting the possibility of large methane eruptions from the seafloor, especially in the Arctic.  Also, the image was recorded later than the image at the top with the 3026 ppb peak, indicating that even more methane may be on the way. This appears to be confirmed by the Copernicus forecast for December 12, 2021, 03 UTC, as illustrated by the image below, which shows methane at 500 hPa (equivalent to 500 mb). Furthermore, ...

Women and children overboard

It's the  Catch-22  of clinical trials: to protect pregnant women and children from the risks of untested drugs....we don't test drugs adequately for them. In the last few decades , we've been more concerned about the harms of research than of inadequately tested treatments for everyone, in fact. But for "vulnerable populations,"  like pregnant women and children, the default was to exclude them. And just in case any women might be, or might become, pregnant, it was often easier just to exclude us all from trials. It got so bad, that by the late 1990s, the FDA realized regulations and more for pregnant women - and women generally - had to change. The NIH (National Institutes of Health) took action too. And so few drugs had enough safety and efficacy information for children that, even in official circles, children were being called "therapeutic orphans."  Action began on that, too. There is still a long way to go. But this month there was a sign that ...