2 Replies Latest reply on Aug 24, 2009 6:26 AM by davekul

    how to automate two images in a continual loop

    davekul

      I'm a newbie to Flex and would like to take two images that I have and basically display them in the same spot one after another in a continuous loop (cheap automation?).  I looked into different effects like Fade, but am stumped how to do something like this in continuous loop.  Most samples show different effects as a result of clicking a button or mousing over an image ...  thanks!

        • 1. Re: how to automate two images in a continual loop
          babo_ya Level 3

          <?xml version="1.0" encoding="utf-8"?>

          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"

           

          creationComplete="init();"

          layout="absolute">

           

           

           

           

           

           

          <mx:Script>

          <![CDATA[

          import mx.core.UIComponent;

           

          [Bindable]

          private var vs:int = 0;

           

           

           

          private function init():void

          {

          var timer:Timer = new Timer(3000);

          timer.addEventListener(TimerEvent.TIMER, onTimerStart);

          timer.start();

          }

          private function onTimerStart(event:TimerEvent):void

          {

          if(vs == 0)

          vs = 1;

          else

          vs = 0;

          }

           

           

          ]]>

          </mx:Script>

           

           

          <mx:ViewStack width="100%" height="100%" selectedIndex="{vs}">

           

          <mx:VBox width="100%" height="100%" showEffect="Fade">

           

          <mx:Image source="1.jpg" />

           

          </mx:VBox>

           

          <mx:VBox width="100%" height="100%" showEffect="Fade">

           

          <mx:Image source="2.jpg" />

           

          </mx:VBox>

           

           

          </mx:ViewStack>

           

           

           

           

           

           

          </mx:Application>

          Hope this helps..
          BaBo,

          • 2. Re: how to automate two images in a continual loop
            davekul Level 1

            Thanks!  I adapted it to what I needed.   I found that also specifying hideEffect="Fade" smoothed the transition between the images.