0 Replies Latest reply on Apr 16, 2010 11:17 PM by lite_As_AIR

    Clipboard in AIR


      is it possible to paste transparent bitmaps to the stage ?


      the code below creates a movieclip with a circle of radius 100; when the user clicks the copy button it converts the movieClip to a bitmap with a transparent background fill and sets the clipboard with the bitmap data.


      The problem is when i paste this bitmap data to stage the bitmap looses its transparency and instead a black background is displayed.


      the flash file consists of 2 buttons CopyBtn and PasteBtn and the following action script document class :



         public class Clipboard_With_Air extends MovieClip

            private var sp:Sprite;
            private var bm:Bitmap;
            private var gr:Graphics;
            private var mc:MovieClip;
            private var bd:BitmapData;
            public function Clipboard_With_Air():void
               //create a movie clip mc with a red circle of radius 100//

               sp = new Sprite();
               mc = new MovieClip();
               gr = sp.graphics;
               gr.beginFill(0xff0000, 1);        
               gr.drawCircle(100, 100, 100);
               gr.endFill() ;
               CopyBtn.addEventListener(MouseEvent.CLICK, onCopyClick)
               PasteBtn.addEventListener(MouseEvent.CLICK, onPasteClick);
            private function onPasteClick(e:MouseEvent):void
               try {
               catch(e:Error) {

               //transparency is lost ??//

               bm = new Bitmap( Clipboard.generalClipboard.getData(ClipboardFormats.BITMAP_FORMAT) as BitmapData);
               bm.x = Math.random() * 800;
               bm.y = Math.random() * 600;


            private function onCopyClick(e:MouseEvent):void
               // create a transparent bitmap out of the movieclip mc which contains a red cirlce of radius 100//
               bd = new BitmapData(mc.width, mc.height,true,0);
               Clipboard.generalClipboard.setData(ClipboardFormats.BITMAP_FORMAT, bd);        


      any help is appreciated thanks !