2010-04-12 16 views
0

所以我有這樣的代碼爲我的應用如何從FLEX應用程序中取出「打印屏幕」並將其保存到硬盤上?

<?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> 

我想它的東西,如「打印屏幕」保存到用戶的硬盤驅動器上按一下按鈕。

如何杜這樣的事情?

回答

2

不幸的是,你不能打印整個用戶的桌面屏幕,你只能「打印屏幕」的Flash文件。下面的僞代碼:

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)); 
+0

哦,是的,要做到這一點,你需要目標Flash Player 10 – ansiart 2010-04-12 17:43:29

+0

這是完全正確的。然而,應該注意的是,通過讓一個代理應用程序(使用其他技術,可能是Java)拍攝並將其發送回Flash應用程序,可以捕獲整個屏幕。如果你正在開發一個AIR應用程序,這可能會起作用,但對於一個Web應用程序,我認爲你不幸的是你運氣不好。 – 2010-04-12 17:49:09

相關問題