1 Reply Latest reply on Dec 7, 2006 4:01 AM by iquaaani

    How to add Bitmap to the display list?

    iquaaani Level 1

      i'm generating Bitmap and i want to show it on UI. How do i do it ? do i have to use UIComponent, box, canvas or something where i can put my generated bitmap.

      For Example i assume that i have :

      <mx:Canvas x="10" y="10" width="327" height="273" id="surface" creationComplete="DrawBitmap()">

      private function DrawBitmap() : void
      var bitmap:BitmapData = new BitmapData(100,100,true,0x00FFFFFF);
      var image:Bitmap = new Bitmap(bitmap);
      This gives me an error
      Type Coercion failed: cannot convert flash.display::Bitmap@7023241 to mx.core.IUIComponent.
      Do i have to make UIComponent somehow ?

      I would appreciate a little example code very much, i'm just a beginner with flex and AC

      Thanks :D
        • 1. Re: How to add Bitmap to the display list?
          iquaaani Level 1
          I found the way, don't know if it is very smart - hey but it works

          Here is the canvas

          <mx:Canvas x="10" y="10" width="327" height="273" id="surface">

          And the script:

          private function DrawBitmap() : void
          import flash.display.Graphics;
          import flash.display.BitmapData;
          import mx.core.UIComponent;

          var bitmap:BitmapData = new BitmapData(100,100,true,0xFF007090);
          var image:Bitmap = new Bitmap(bitmap);
          var mySprite:Sprite = new Sprite();
          var bitmapHolder:UIComponent = new UIComponent();