0 Replies Latest reply on Jan 31, 2011 9:50 AM by Miggl

    How to Crossfade and Resize Embedded Images?

    Miggl Level 1

      Hi all,


      I have successfully figured out how to crossfade images, the only problem is that I don't know how to resize them?

      The crossfade target is an image that spans the entire width and height of the screen, and it has scaleContent set to true, so that the images will fill the screen.


      The images that are being crossfaded are embedded images using the following syntax:


      private const image1:Class;

      These are not he same size as the target image, and so when the crossfade completes, they snap to the scaled size to fill the screen. My questions is: how do I get the embedded images resized prior to the crossfade, so that the crossfade already fills the screen?
      Here is my code:
      <?xml version="1.0" encoding="utf-8"?>
                <s:Transition autoReverse="true" />
                     import mx.collections.ArrayCollection;
                     import mx.core.BitmapAsset;
                     import mx.events.FlexEvent;
                     import mx.graphics.BitmapFill;
                     private var timer:Timer;
                     private var i:uint = 1;
                     private const image1:Class;
                     private const image2:Class;
                     private function application_creationCompleteHandler(event:FlexEvent):void
                          timer = new Timer(7000);
                          timer.addEventListener(TimerEvent.TIMER, runCrossfade);
                     private function runCrossfade(event:Event):void
                          var image_from:Class;
                          var image_to:Class;
                          if (this.timer.currentCount % 2 == 0)
                               image_from = this["image2"];
                               image_to = this["image1"];
                               this.i = 1;
                               image_from = this["image" + i];
                               image_to = this["image" + (i + 1).toString()];
                          this.crossfade.bitmapFrom = new image_from().bitmapData;
                          this.crossfade.bitmapTo = new image_to().bitmapData;
                          this.img_background.source = new image_to;


      Any ideas are appreciated.