I think you can use the ImageSnapShot class, and thern use the bitmap data from it as you desire.
You can use the snapshot to take a grab of any element/child in your application or presumably you can take a snapshot of the main application if you want the whole lot.
I used this method recently to print a screen state.
var imgWidth:Number = 400; var img:SWFLoader = new SWFLoader(); img.id = "appSnapShot"; var imageSnap:ImageSnapshot = ImageSnapshot.captureImage(myScreenInstance as IBitmapDrawable); var imageByteArray:ByteArray = imageSnap.data as ByteArray; img.load(imageByteArray); img.scaleContent = true; img.width = imgWidth; img.maintainAspectRatio = true; application.addElement(img);
Maybe that will help.
Thanks for reply. But I want to take complete screen-shot of the whole screen.
//Hope this logic you have written in your main application
var imageSnap:ImageSnapshot = ImageSnapshot.captureImage(this as IBitmapDrawable);
You want to take a screenshot of the operating system desktop and not of the AIR application?
I don't know how/if this can be done in AIR 2.0 on its own, though I did see this... which might be relevant to your question. It appears to use merapi as a bridge to java, which is used to take a screen cap.
Allowing AIR applications to take screen shots is a security issue. This should not be made a feature to AIR developers. There is no reason for it. Let the user take control of his/her own screen snapshot instead of letting a rogue AIR app take screen shot instances in the background and transferring to their servers. Also consider multiple screen displays as well - not just the main screen the app is running on.
I'd be pissed if I had documents up and they were captured and sent to prying eyes by Adobe AIR.
The way you get get around having a "rogue AIR app" taking screenshots is to not install it. Adobe AIR runs on the desktop and should have the ability to do anything that any other desktop application can do. The usefulness of giving the user the ability to take a screenshot inside Adobe AIR far outweighs any perceived security risk of some nefairius app that does one thing to trick you to install it, but really sits around taking covert screenshots and sending them to their servers. Respectfully... you're being paranoid.