Flex Transitions and Effects – Part 1

Flex IconOne of the more interesting aspects of Flex development is the ease and flexibility in which you can add that extra level of polish that good interactive solutions are known for. I’m not referring to good creative, but to transitions and effects; in other words how the user gets from one screen or area to another within your application without it being a first in first out style interaction

This is one aspect of Flex development that places it above other rapid development solutions

For the uninitiated Effects like most things in Flex are usually declared in MXML (but as with everything else in the Flex framework they can be instantiated in ActionScript as well – see the more advanced examples below). The basic structure of an effect is as follows:

As you can see it is pretty much the same structure as any other MXML tag. The nice thing about effects is that you can string them together to form more complex visual displays. So for example if we wanted to have a panel grow in size and move once it was at the right size we can easily do this using a <mx:Sequence/> tag to wrap a <mx:Resize/> and a <mx:Move/> effect together we can simply do this as shown below. As you can see as it is wrapped within a Sequence block so that the Resize effect executes first; then once it has finished the Move effect is executed

One thing to keep in mind is that if you set a duration within the <mx:Sequence/> tag the amount isn’t divided between the elements in encapsulates. So if you set the duration to 1000 (1 second) the <mx:Resize/> and <mx:Move/> effects in the previous example would run for 1 second not 500 milliseconds each.

If you want to combine your effects then you can simply replace the Sequence tag with a Parallel tag. This will execute any effects that it encapsulates simultaneously. Again, if you set the duration in the <mx:Parallel/> tag the combined effects will take the total time to complete.

Now once you are happy with the basic effects and combining them you can start to create some interesting visual displays. The main thing to note is that if you just wanted to target a specific effect at a component of your choice you don’t have to create a new effect to do this. You can just provide your effects individual IDs and then apply any of them to any target you feel like. So if you update the effects inside the <mx:Parallel/> block with individual IDs you can then invoke any of the effects directly.

If you try out the example above you’ll see that if you click the second button, called “Resize my container” it not only resizes, but moves the Panel. However if you click the button called “Move ME” it accesses only the <mx:Move/> effect of the <mx:Parallel/> effect block.

That’s it for this part. Next time we’ll look at instantiating effects in ActionScript.


2 comments for “Flex Transitions and Effects – Part 1”

  1. […] Flex Transitions and Effects – Part 1 Flex 3 Wipe […]

    Posted by FlashGen.Com .: blog :. » Flex 3 Wipe Effects | November 14, 2008, 13:59
  2. Posted by Tink | January 28, 2009, 10:30

Post a comment