0

So I have such code for my application

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">

    <fx:Script>
        <![CDATA[
            protected function prtscrn_clickHandler(event:MouseEvent):void
            {
                // save current RIA view as a PNG or JPG to users FileSistem
            }
        ]]>
    </fx:Script>

    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:Button x="21" y="10" label="Print Screen" id="prtscrn" click="prtscrn_clickHandler(event)"/>
    <s:TitleWindow x="45" y="98" width="282" height="303">
        <s:CheckBox x="25" y="10" label="CheckBox"/>
        <s:Button x="24" y="44" label="Button"/>
        <mx:DateChooser x="24" y="76"/>
    </s:TitleWindow>
</s:Application>

I want to save Its something like "Print Screen" to users hard drive on button click.

How to du such thing?

Rella
  • 65,003
  • 109
  • 363
  • 636

1 Answers1

2

Unfortunately you can't Print Screen the whole user's desktop, you can only "Print Screen" the flash file. Pseudo-code below:

var b:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight);
b.draw(stage);

// create reference that will be the saved file
var ref:FileReference = new FileReference();

// add listeners for filereference ...

// save the bitmapdata
ref.save(b.getPixels(b.rect));
ansiart
  • 2,563
  • 2
  • 23
  • 41
  • oh yes, to do this you'll need to target flash player 10 – ansiart Apr 12 '10 at 17:43
  • This is completely correct. However it should be noted that it is possible to capture the whole screen by letting a proxy application (using some other tech, perhaps Java) take the picture and sending it back to the Flash application. This may work if you're developing an AIR application, but for a web application I think you're out of luck unfortunately. – Marcus Stade Apr 12 '10 at 17:49