Flex 4: Getting bitmap data on a spark clipped content

Recently I was working on a project where I need to get the bitmap data from a container which had a scroller. From Flex 3 I tried to simply get the content directly from container; but I noticed that I only got the exact image of the scroller (Viewport) instead the full content.

With some playing, I got to the same easy solution; to draw the entire content of the container is to simply disable the clipAndEnableScrolling property over the container I was going to fetch the bitmap data and after drawing, enable again; as internally it just adjust the view properties, you won’t notice the change.

Here is the snippet:

this.containerDraw.clipAndEnableScrolling = false;
bmSave.draw(this.containerDraw);
this.containerDraw.clipAndEnableScrolling = true;

Where bmSave it’s a BitmapData, you can see an example here:

http://code.danguer.com/flex/clip-container

Share