Home > Adobe Flex > Creating Flex Sequence Effects in ActionScript

Creating Flex Sequence Effects in ActionScript

I just started building a small administrative application and in addition to having the 24 Hour Fitness logo appear in the upper left-hand corner of the main Panel, I wanted to spice it up with a cutesy bounce effect.

At first, I created my own bounce effect by using the Sequence effect, shipped in the Flex SDK’s effects package (mx.effects.Sequence). The Sequence effect “plays multiple child effects one after the other, in the order in which they are added”. The sequence effect would combine a series of AnimateProperty effects (mx.effects.AnimateProperty) that would move the “y” value of an image from a starting y-position value to an end y-position value and then back and forth to simulate an object bouncing:

1
2
3
4
5
6
7
8
9
10
11
<!-- Define factory sequence class -->
<mx:Sequence id="bounceSeq">
	<mx:AnimateProperty property="y" fromValue="-70" toValue="45" duration="500"/>
	<mx:AnimateProperty property="y" fromValue="45" toValue="-35" duration="450"/>
	<mx:AnimateProperty property="y" fromValue="-35" toValue="35" duration="350"/>
	<mx:AnimateProperty property="y" fromValue="35" toValue="-15" duration="250"/>
	<mx:AnimateProperty property="y" fromValue="-15" toValue="30" duration="150"/>
	<mx:AnimateProperty property="y" fromValue="30" toValue="5" duration="150"/>
	<mx:AnimateProperty property="y" fromValue="5" toValue="25" duration="150"/>
	<mx:AnimateProperty property="y" fromValue="25" toValue="23" duration="150"/>
</mx:Sequence>

I gave the first fromValue a starting position of “-70″, which for this application meant the logo would first appear off-screen. But in the end, I had trouble configuring the values to make the bounce look right. I also had trouble moving the sequence component inside it’s own mxml class definition since flex effects aren’t listed as the typical UI Components used as mxml components.

So I decided to write an ActionScript version of a Sequence effect. It was then I discovered that Flex already had incorporated several easing behaviors into the effects package. Great news!

I set off to write a sequence effect class in ActionScript that incorporated the Move easing effect. The class was incredibly easy to write since the Sequence class itself contains only one method (initInstance). By overriding that method, creating a new Move easing effect and adding that object to as a child to the sequence, the bounce effect I was looking for was easily achieved:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package 
{
	import mx.effects.IEffectInstance;
	import mx.effects.Move;
	import mx.effects.Sequence;
	import mx.effects.easing.*;
 
	/**
	 * Custom sequence to depict bounce effect
	 */
	public class Bounce extends Sequence
	{
		public function Bounce()
		{
			super();
		}
 
		override protected function initInstance( instance : IEffectInstance ) : void
		{
			//create new Move effect
			var _move : Move = new Move();
				_move.yBy = 92;  //specific to this particular example
				_move.duration = 2000; //in milliseconds
				_move.easingFunction = mx.effects.easing.Bounce.easeOut;
 
			//add Move effect as a child to this sequence
			this.addChild( _move );
 
			//call super to ensure parent's original logic is still executed
			super.initInstance( instance );
		}
	}
}

Now as you might have noticed, this sequence contains only one effect (Move), but multiple effects could be added easily to the method above by creating a new Effect and adding it as a child to the Sequence object.

The end result looks like this (click to restart animation):

Categories: Adobe Flex Tags:
  1. May 14th, 2009 at 11:00 | #1

    Great post! Good examples and explanation. I really like how you offered a before/after type example. The effect looks great!

  2. August 21st, 2009 at 20:51 | #2

    Enjoyed the post. I think it is a nice, clean way to add the effects to a Flex application. Thanks!

  3. Vito
    October 3rd, 2009 at 08:02 | #3

    would have saved you some effort

  4. May 29th, 2014 at 02:18 | #4

    I quite like reading a post that can make people think.
    Also, many thanks for allowing for me to comment!

  5. July 9th, 2014 at 01:39 | #5

    Superb post however , I was wanting to know if you could write a litte more on this subject?
    I’d be very thankful if you could elaborate a little bit further.
    Cheers!

  6. June 11th, 2020 at 04:42 | #6

    Say, you got a nice blog article.Really looking forward to read more. Really Cool. sex animation

  7. June 17th, 2020 at 06:51 | #7

    Woman of Alien Great do the job you ave carried out, this website is de facto interesting with amazing information. Time is God as method of preserving everything from occurring at once.

  8. June 22nd, 2020 at 05:13 | #8

    Thanks for sharing, this is a fantastic article post.Really looking forward to read more. Awesome.

  9. June 22nd, 2020 at 06:46 | #9

    you ave gotten an awesome weblog right here! would you prefer to make some invite posts on my blog?

  10. June 26th, 2020 at 03:16 | #10

    You are my inhalation , I own few web logs and occasionally run out from to post.

  11. June 29th, 2020 at 06:34 | #11

    Yes. It should work. If it doesn at send us an email.

  12. July 8th, 2020 at 10:53 | #12

    Its hard to find good help I am forever proclaiming that its hard to find good help, but here is

  13. July 19th, 2020 at 11:36 | #13

    Really enjoyed this post.Thanks Again. Great.

  14. July 26th, 2020 at 23:47 | #14

    This is one awesome article.Much thanks again.

  15. August 6th, 2020 at 09:42 | #15

    This is one awesome post.Much thanks again. Great.

  16. August 17th, 2020 at 09:24 | #16

    I truly appreciate this blog post.Much thanks again. Fantastic.

  17. September 6th, 2020 at 07:54 | #17

    I?ve learn a few good stuff here. Definitely price bookmarking for revisiting. I surprise how a lot attempt you set to create this type of fantastic informative web site.

  18. April 30th, 2021 at 00:10 | #18

    Somebody necessarily lend a hand to help make significantly articles I may state.
    That may be the first time I frequented your webpage and
    thus far? I amazed together with the analysis you created to create this type of submit extraordinary.
    Magnificent task!

  19. June 21st, 2021 at 00:45 | #19

    It’s genuinely very complex in this busy life to
    listen news on Television, therefore I only
    use web for the reason, and take the latest news.

  20. November 14th, 2024 at 00:28 | #20

    Amazing issues here. I amm veryy satisfied too look you article.

    Thanks so much annd I’m havibg a lokk forward too contact you.

    Will you pkease drp mee a mail?

  1. No trackbacks yet.