You want to take a snapshot of a Flex container or control at runtime and save it as a BitmapData object.
The following example shows how you can take a snapshot of an item on the display list using the static ImageSnapshot.captureBitmapData() method, which returns a BitmapData object, as seen in the following snippet: var imageBitmapData:BitmapData = ImageSnapshot.captureBitmapData(source); swfLoader.source = new Bitmap(imageBitmapData);
<mx:Script>NOTE: The ability to load a ByteArray object directly into a SWFLoader control was added in Flex 3 build 187814.
<![CDATA[
import mx.graphics.ImageSnapshot;
private function takeSnapshot(source:IBitmapDrawable):void {
var imageBitmapData:BitmapData = ImageSnapshot.captureBitmapData(source);
swfLoader.source = new Bitmap(imageBitmapData);
}
]]>
</mx:Script>
<mx:Array id="arr">
<mx:Object col1="Row 1, Col 1" col2="Row 1, Col 2" />
<mx:Object col1="Row 2, Col 1" col2="Row 2, Col 2" />
<mx:Object col1="Row 3, Col 1" col2="Row 3, Col 2" />
<mx:Object col1="Row 4, Col 1" col2="Row 4, Col 2" />
<mx:Object col1="Row 5, Col 1" col2="Row 5, Col 2" />
<mx:Object col1="Row 6, Col 1" col2="Row 6, Col 2" />
</mx:Array>
<mx:ApplicationControlBar dock="true">
<mx:Button label="Take snapshot of DataGrid"
click="takeSnapshot(dataGrid);" />
</mx:ApplicationControlBar>
<mx:HBox>
<mx:DataGrid id="dataGrid" dataProvider="{arr}" />
<mx:SWFLoader id="swfLoader">
<mx:filters>
<mx:DropShadowFilter />
</mx:filters>
</mx:SWFLoader>
</mx:HBox>
For more information, see http://blog.flexexamples.com/2007/11/17/taking-screenshots-in-flex-3-using-the-imagesnapshotcapturebitmapdata-method/ and http://blog.flexexamples.com/tag/imagesnapshot/.