Animation effects with ActionScript 3, Flex 4 and Spark
Flex 4 introduced the Spark component, which is now recommended by Adobe instead of older libraries. In the new spark.effects package there are a lot of different effects, but all of them are quite similar. I will use the AnimateColor effect to explain how to create animations with Spark.
First of all, you need to import the appropriate class:
- import spark.effects.AnimateColor;
Then, you define the attributes of the animation:
- var animation:AnimateColor = new AnimateColor(this);
- animation.duration = 400; // milliseconds
- animation.colorFrom = 0xFFCC00;
- animation.colorTo = 0xaaff00;
- animation.colorPropertyName = "color";
Finally, you use the play function when you want your effect to begin. It is recommended to call stop() before play() to stop it in case it was playing before.
- animation.stop();
- animation.play();
Remember to check the spark.effects package documentation to discover all possibilities.
Submitted by miguelSantirso about 1 year ago — last modified less than a minute ago