2 Replies Latest reply on Jul 27, 2009 11:18 AM by ginko-dave

    DataGrid not rendering images during scrolling

    murfmee
      I've created a "Reusable Inline Item Renderer" to display an image in a DataGrid's column, as is shown here:

      http://www.adobe.com/devnet/flex/quickstart/using_item_renderers/#reusable_item

      With one difference: In the example the source of the Image component in the item rendered is being set to the URL of an image file. In mine I am setting the source as a Bitmap object, the Bitmap being a public and Bindable property of an Object in an Array. This Array of Objects is the DataGrid's dataProvider.

      And it works fine, except that when I scroll the DataGrid, any images that have been scroll off screen and then back on again are blank where the image used to be. I've tried tracing out the source of each Image when it renders and it still has a Bitmap object as it's source even though it is no longer displaying it.
        • 1. Re: DataGrid not rendering images during scrolling
          murfmee Level 1
          I found a solution:

          Rather than set the "source" of the Image component in my item renderer to the Bitmap in an object in the array, I created a new Bitmap object inside of the item rendered, using the BitmapData in the object in the array, and then set the source of the Image component in the item rendered to the new local (to the item rendered) Bitmap object.

          Voila! No more dissapearing Images. :)
          • 2. Re: DataGrid not rendering images during scrolling
            ginko-dave

            I have been beating my head against the wall on this problem too for awhile now.  There is precious little mentioned anywhere about it.

             

            I tried to recreate your code, as follows, to solve my problem but now am getting compilation errors.

             

            Can you please share your code segment on how you did it?    (It would also be helpful to see how you call it too.)  I am loading images from the web with Loader.

             

            This does not compile:

             

                    public function get data():BitmapData {
                        return _data;
                    }

                    public function set data(value:BitmapData):void {
                        _data = value;
                         var newBitmap:Bitmap = new Bitmap(value);
                        source = newBitmap;
                    }

             


            In my main class, the data provider is already populated, so I am replacing the cell with the bitmap.

             

            Thanks for any help you can give.