1 Reply Latest reply on Sep 15, 2010 7:09 PM by codecus

    display image in standalone AIR application


      I have loaded images and like to display image in standalone AIR application. But I cannot get it work. The code as follows:



      private function ImageLoader(url:String):void


      var request:URLRequest = new URLRequest(url);

      var loader:Loader = new Loader();

      loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderComplete);




      private function loaderComplete(event:Event):void


      var scaleFactor:Number = 1;

      var uic:UIComponent = new UIComponent();




      var bmp:Bitmap = event.target.content as Bitmap;

      var bmd:BitmapData = bmp.bitmapData; //Bitmap(event.target.content).bitmapData;

      var scaledBMD:BitmapData = new BitmapData(400, 400);

      var matrix:Matrix = new Matrix();

      matrix.scale(scaleFactor, scaleFactor);

      scaledBMD.draw(bmd, matrix, null, null, null, true);

      uic.x = 40;

      uic.y = 40;

      uic.addChild(new Bitmap(scaledBMD));


      catch (errObject:Error)





        • 1. Re: display image in standalone AIR application
          codecus Level 1

          Found answer by adding mx:Canvas and add



          uic.addChild(new Bitmap(scaledBMD));


          <mx:Canvas id="iconCanvas" width="10" height="10" horizontalScrollPolicy="off" verticalScrollPolicy="off" x="0" y="0" clipContent="false"/>


          Is anyone create "Canvas" by using new Canvas and get it works? example:

          var canv:Canvas = new Canvas(...);