2010-06-12 6 views
1

Suivi de: As3 printing problem, blanks swf after print or cancelImprimer un bitmap sans imprimer un sprite?

Je suis en train de comeup avec une fonction d'imprimer sans créer une image-objet, parce que ce qu'il semble poser mon problème:

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") 

     } 
    } 

Cela vient avec un :

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

Alors, comment imprimer un bitmap sans créer un Sprite?

Répondre

0

Je ne l'impression essayé ... mais cela pourrait aider: pJob.addPage attend un sprite .. donc fournir avec celui qui est wraping votre bitmap comme ceci:

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

J'espère que cela fonctionne