3 Replies Latest reply on Dec 14, 2011 4:31 PM by Flex harUI

    flex 3.6 bitmap losing data


      I am losing the bitmapdata inside of the bitmaps image1 and image2 in the code below, its happening after the first round of ticks,


      so the first tick it loads image1 fine, second tick loads image 2 fine, after that the bitmaps have no data in them.


      <?xml version="1.0" encoding="utf-8"?>

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="1000" minHeight="1000" creationComplete="create()">



                                    var imagexml:XMLList;



                                    private var tempTimer:Timer = new Timer(2000,0);

                                    private var url1:Loader = new Loader();

                                    private var url2:Loader = new Loader();

                                    private var image1:Bitmap;

                                    private var image2:Bitmap;


                                    private function create():void{


                                              url1.load(new URLRequest("com/imaging/assets/image1.jpg"));



                                              url2.load(new URLRequest("com/imaging/assets/image2.jpg"));









                                    private function image1load(event:Event):void{


                                              var _image1:Bitmap = url1.content as Bitmap;

                                              image1 = new Bitmap(_image1.bitmapData);



                                    private function image2load(event:Event):void{

                                              var _image2:Bitmap = url2.content as Bitmap;

                                              image2 = new Bitmap(_image2.bitmapData);




                                    private var i:int=0;

                                    private function tick(event:TimerEvent):void{


                                                        i = 0;





                                                        i = 1;





                                    protected function left(event:MouseEvent):void













                <mx:Image id="imagePlace" height="1000" width="1000"  />


                          <mx:Button label="Left" click="left(event)"  />

                          <mx:Button label="Right" />





        • 1. Re: flex 3.6 bitmap losing data
          Flex harUI Adobe Employee

          Flex will release the bitmap data when the source changes.  It is probably better to switch between two mx:Images than to try to switch the source.

          • 2. Re: flex 3.6 bitmap losing data
            felipe-kwh Level 1

            Yes I was able to do this as well by creating a new image. Is there no flag/method for prevening flex from releasing that data?


            What I am most concerned about is that flex is releasing the bitmap data on a bitmap that while it is  used as the source for an image it is still its own object and entity. It seems sort of arbitrary to in this one case say, oh I am goign to release the objects you are hodling in memory because it is no longer being used in this image (even though the bitmap could be tied up doing other things).

            • 3. Re: flex 3.6 bitmap losing data
              Flex harUI Adobe Employee

              Yeah, I think it is a bug.  Either we can’t tell or didn’t check that the image is loaded externally or is embedded.  The intent was to auto-dispose external bitmaps otherwise they won’t get garbage collected