2010-06-12 157 views
1

從隨訪:As3 printing problem, blanks swf after print or cancel打印位圖而不打印精靈?

我想用的功能,而無需創建一個精靈打印到川方,因爲這是它似乎導致我的問題:

public function printScreen():void { 


     var pJob:PrintJob = new PrintJob(); 

     var options:PrintJobOptions = new PrintJobOptions(); 
     options.printAsBitmap = true; 

     var bitmapData:BitmapData = new BitmapData(root.width, root.height); 
     bitmapData.draw(root); 

     var printThis:Bitmap = new Bitmap(bitmapData); 


     try { 

     pJob.start(); 


     pJob.addPage(printThis, null, options); 
     pJob.send(); 

     } 

     catch(e:Error) 
     { 


     trace("Error Printing") 

     } 
    } 

這是未來與一個:

Error: Description Implicit coercion of a value of type flash.display:Bitmap to an  unrelated type flash.display:Sprite. 

那麼如何在不創建Sprite的情況下打印位圖?

回答

0

我從來沒有嘗試過的印刷......但,這可能幫助: pJob.addPage期待一個精靈..所以它提供一個真實包木窗您的位圖是這樣的:

var s:Sprite = new Sprite(); 
s.addChild(printThis); 
pJob.addPage(s, null, options); 
pJob.send(); 

我希望它的工作原理