views:

43

answers:

2

Hi all,

I'm quite new to Flex.

I've looked into taking screenshots in flex and have found many links on google and here on stackoverflow for taking screenshots of components and stuff like this. What I would like to do is take a screenshot of the entire tab in a browser window (or, failing that, the browser window itself or even just the screen).

I'm able to take a screenshot of a viewstack because it implements the IBitmapDrawable interface. But what if I want to take a screenshot of the browser tab as mentioned? Is this possible and, if so, how?

The parent of the viewstack is the application but when trying to pass Application.application to the draw method of the BitmapData class, I get the following error:

Implicit coercion of a value with static type Object to a possibly unrelated type flash.display:IBitmapDrawable.

Thanks in advance.

+1  A: 

Sorry, but it is not possible to take screenshots of the complete browser window or tab. You can also capture what runs inside of Flash Player. This is a security issue.

When dealing with Adobe Air applications, this is different, as you have a stronger connection to native OS functions.

If this helps, please vote for the answer.

Czar
Thought I already commented on this. Thanks for the info. Tried to vote up on your answer but found that I need more reputation before I can.
the_new_mr
+1  A: 

It's not possible to take screenshots of anything that's outside of your Flex application. However, it should be possible to take a screenshot of your application. Application is a DisplayObject which implements IBitmapDrawable. The reason for your error is, that Application.application is of type Object. So, you should be able to cast your application as IBitmapDrawable and use it to get a screenshot of your application.

// Flex 3.x
var app:IBitmapDrawable = Application.application as IBitmapDrawable;

// in Flex SDK 4.x Application.application is deprecated so use
var app:IBitmapDrawable = FlexGlobals.topLevelApplication as IBitmapDrawable;
Gerhard
I have deleted my answer in favor of yours.
splash
Thanks man. Not exactly what I was looking for but if you can't take screenshots of anything outside of the flex app then taking the screenshot of the flex app itself is the next best thing.I would have thought that if Application is a DisplayObject then there would be no need to cast it but never mind.Much appreciated. It worked very nicely :)
the_new_mr