« [OT] : Job opening for Flash Developers in Chennai, India | Main | Math – MathML & Flash – What I have been doing lately »

Detecting Print Screen in Flash

Listen to this article Listen to this article :: Talkr

This should be probably the nth time somebody has asked me about this. Thought I will just blog this so someone else who is looking for the same solution would find this useful.

For capturing Print Screen, the traditional Key.addListener(myListener); method wouldn't work and the alternative which I use on my projects is this one and it works:

this.onEnterFrame = function (){
if (Key.isDown(44)) {
trace("Dont try to capture me!");
}
}

Usually this method is used to prevent the user from capturing the screen but definelty this is not a 100% fool prrof method and by the time Flash detects the key press and does something - Windows would have already captured the screen. But yes if you want to warn your user not to take a screen shot you can use this.

If someone out there know of a better solution just post a comment and let the world know of it.

|

TrackBack

TrackBack URL for this entry:
http://www.lastashero.com/blog/mt-tb.cgi/24

Comments

KP,
Though this code would help you show a fake alert to the user, effectively the printscreen will succeed.

What I would suggest is this:

this.onEnterFrame = function (){
if (Key.isDown(44)) {
trace("Dont try to capture me!");
System.setClipboard("Dont try to capture me!");
}
}

This way, you'll be able to clear the clipboard off the bitmap that was captured, and put up some text of your choice.

Doesn't that solve your problem ?

Well said Arul ! This is the best solution as far as I know. In my case I wasn't able to use this really because the application was a authoring tool and I have been using System.setClipboard to set some XML string to the clipboard and I didnt want to mess around with the clipboard.

Neverthless, this is the best solution for the screen capture problem.

- kp

Hi !
Can't we find a solution without testing onEnterFrame ?
The onKeyDown function wouldn't do the thing ?

It's too much bother for nothing.
Unless the app you are working on is for an intranet, it's impossible to prevent user from capturing the screen when the RIA is deployed.

http://www.faststone.org/FSCaptureDetail.htm

In the browser, Flash needs focus to detect that the key is down.

Mike: You are true in the sense that there is no 100% fool proof method to prevent someone from capturing the screen but these solutions are just ways to avoid as much as we can. How many people out there would know of the software you mentioned and how many of them would actually take out the time to go and find one just for this purpose.

All said, these solutions are meant only for not-so-technical people - one can even take the SWF from the cache decompile it and simulate the same screen even :)

-kp

Robert - You are a perfectly correct that Flash needs to be focused to detect the key. The way we do this is, we have a JavaScript function on the HTML page which can easily detect Print Screen and and take corrective actions and in Flash we have the key detection.

-kp

I'd be interested in what JS you're using. But Robert is right, unless Flash is in focus it won't be able to detect the print-screen (and the browser window isn't the only item that can have focus).

If there is a way to detect if Flash has lost focus than you could replace copyrighted material with a "click here to see..." message, bringing back the focus. I've messed around with it for a while however and can't find a solution.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Recent Visitors

Feeds


Link to Podcast (RSS feed) for this blog

Aggregated By :