Using the AnimateProperty Effect

I’ve been using the AnimateProperty effect a lot lately for creating single or compound effects in Flex, so I thought I’d share a few simple examples. The AnimateProperty effect not only allows you to animate a property like width, height, etc., but it also allows you to animate a style property as well, so you can really get into the details of how you want a component to animate. Here’s some quick examples:

You can recreate the Resize, Fade, and Move effects by using the AnimateProperty effect and animating size, position and alpha:

Click here to view source

With the AnimateProperty effect you can also animate certain styles by setting isStyle=”true” in the effect properties. This allows you to do things like animate the cornerRadius and fontSize of a Button:

Click here to view source

Like I said, these are simple examples, but with a little experimentation you can add another level of detail to any effect you might be trying to create and it some cases have a bit more control.

7 Responses to “Using the AnimateProperty Effect”

  1. Jim Rutherford Says:

    Very nice! I’ve been using Tweener to do some of these effects. Not anymore!

  2. steve Says:

    HI, that’s great! thanks,
    Can you show us an example tilelist transition effects where you have a tilelist and slider and when you move the slider objects in the tilelist fadeout and delete.
    thanks,

  3. Mark Says:

    This is amazing how little code is involved to produce these effects.

  4. Ryan Says:

    This is very cool being able to animate styles. I looked into the source of AnimateEffect and it uses the setStyle method to modify the style incrementally. Recently I heard from one of the Flex engineers that calling setStyle is one of the most expensive operations in the framework so I’m wondering if it’s realistic to use this in real-world applications. If the performance isn’t affected too negatively then great, but I’m a bit wary.

    Ant thoughts/experiences?

  5. juan Says:

    @Ryan - setStyle is one of the most expensive operations and is also used for doing runtime CSS. I haven’t used any of the isStyle portions of the AnimateProperty effect, but all I can suggest is to use it sparingly and evaluate any negative impacts that may take place, especially any performance hits.

  6. Mathic Says:

    Thanks for easy demo..
    Know some body how to AnimateProperty percentage of width or height?

  7. Sean Says:

    @Mathic - set myAnimateProperty.property = ‘percentWidth’ instead of just ‘width’

Leave a Reply