0 Replies Latest reply on Mar 29, 2007 2:12 PM by csrocks

    Remote image not resizing

    csrocks
      I have created a web service that pulls images (gif) from the database and base64 it for sending across the wire. The flex application then decodes and renders the image. The Image is not being scaled correctly. If I embed the image into the application everything works correctly. But if the image is decoded then sizing goes out the window.

      The image overflows the Image box and takes up the full size of the image. Zoom, rotation, etc. do nothing to the image.

      Any help is appreciated...

      Example Code:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="onLoad(event);">
      <mx:Script>
      <![CDATA[
      import mx.utils.Base64Decoder;
      public function onLoad(event:Event):void {
      // Decode image - Base64 gif image (500 x 776)
      var base64:String = "R0lGOD..."; // Get base64 from web service call
      var decoder:Base64Decoder = new Base64Decoder();
      decoder.decode(base64);

      // Load image into container
      var loader:Loader = new Loader();
      loader.loadBytes(decoder.flush());
      image2.addChild(loader);
      }
      ]]>
      </mx:Script>
      <mx:HBox id="mainBox">
      <!-- Should render a 100 x 100 box but instead the image is full size -->
      <mx:Image id="image2" width="100" height="100" />
      </mx:HBox>
      </mx:Application>