19
Sep
07

Sequencing effects in Flex using the mx:Sequence tag

The following example shows how you can use the <mx:Sequence /> MXML tag in Flex to create combined effects which execute in order. This example shows how to fade a display object in, pause, and then fade a display object out. Also, the same thing but with a combination of Wipe effects.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/09/19/sequencing-effects-in-flex-using-the-mxsequence-tag/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Script>
        <![CDATA[
            private function fade_click():void {
                fader.stop();
                fader.play([box]);
            }

            private function wipe_click():void {
                wiper.stop();
                wiper.play([box]);
            }
        ]]>
    </mx:Script>

    <mx:Sequence id="fader">
        <mx:Fade alphaFrom="0.0" alphaTo="1.0" />
        <mx:Pause duration="{slider.value}" />
        <mx:Fade alphaFrom="1.0" alphaTo="0.0" />
    </mx:Sequence>

    <mx:Sequence id="wiper">
        <mx:SetPropertyAction name="alpha" value="1.0" />
        <mx:WipeRight showTarget="true" />
        <mx:Pause duration="{slider.value}" />
        <mx:WipeRight showTarget="false" />
        <mx:SetPropertyAction name="alpha" value="0.0" />
    </mx:Sequence>

    <mx:ApplicationControlBar dock="true">
        <mx:Button label="fade box"
                click="fade_click();" />
        <mx:Button label="wipe box"
                click="wipe_click();" />

        <mx:Spacer width="100%" />

        <mx:Label text="effect pause ({slider.value} ms):" />
        <mx:HSlider id="slider"
                minimum="1000"
                maximum="3000"
                value="1500"
                labels="[1000,2000,3000]"
                liveDragging="true"
                showTrackHighlight="true"
                snapInterval="100"
                tickInterval="500"
                dataTipPrecision="0" />
    </mx:ApplicationControlBar>

    <mx:Box id="box"
            width="100%"
            height="100%"
            backgroundColor="haloSilver"
            alpha="0.0" />

</mx:Application>

View source is enabled in the following example.


5 Responses to “Sequencing effects in Flex using the mx:Sequence tag”


  1. 1 Venkat from INDIA Nov 22nd, 2007 at 10:28 am

    Hi,

    HOw do I get to apply independent effects on multiple containers in seqenece??

  2. 2 RR Jan 9th, 2008 at 10:45 am

    This was exactly what I was looking for, thanks for sharing!

  3. 3 Allen Apr 23rd, 2008 at 6:59 pm

    Hi,
    Thank you for your tutil ,
    but I don’t know how to create Sequence using actionscript,
    can you teach me?

  4. 4 peterd Apr 23rd, 2008 at 8:43 pm
  5. 5 sesha Jul 21st, 2008 at 1:23 am

    ok it s good

Leave a Reply

This blog is terrible at eating HTML tags. If you plan on posting code/XML, please escape your "<" characters as "&lt;" and your ">" characters as "&gt;".