If I understood correctly your problem.
You can use built in Flex/as3 function to take a screenshot of the entire application or a particular component then convert into bytearray and PngEncoder (or JPGEncoder if you prefer), than save it…
Here’s an example:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
import mx.graphics.codec.PNGEncoder;
private function takeSnapshot(comp:DisplayObject):void {
var bitmapData:BitmapData = new BitmapData(comp.width,comp.height,false,0x00000000);
bitmapData.draw(comp, new Matrix());
var fileStream:FileStream = new FileStream();
fileStream.open(File.desktopDirectory.resolvePath("screenshot.png"), FileMode.UPDATE);
fileStream.writeBytes(new PNGEncoder().encode(bitmapData));
}
]]>
</fx:Script>
<s:BorderContainer width="100%" height="100%" backgroundColor="#ff00ff">
<s:Label text="this text and box should be saved"/>
<s:BorderContainer width="25%" height="25%" backgroundColor="#ffff00" horizontalCenter="0"
id="extended"
verticalCenter="0">
<s:Label text="this text and box should be saved" width="100%" maxDisplayedLines="5"/>
</s:BorderContainer>
</s:BorderContainer>
<s:Button bottom="0" left="0" label="screen" click="takeSnapshot(extended)"/>
</s:WindowedApplication>
EDIT:
As I thought I misunderstood the request..
The only way I can think of is to:
- Minimize the application (
this.minimize();
) or setting the alpha to 0 (this.alpha=0
). - Take the screenshot
- Maximize the application (
this.maximize();
) or setting the alpha to 1 (this.alpha=0
).