打印位图而不打印精灵?
我试图想出一个在不创建精灵的情况下打印的函数,因为这似乎是导致我的问题的原因:
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.
那么如何在不创建精灵的情况下打印位图?
Following up from: As3 printing problem, blanks swf after print or cancel
I am trying to comeup with a function to print without creating a sprite, because that's what it seems to be causing my problem:
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")
}
}
This is coming up with an:
Error: Description Implicit coercion of a value of type flash.display:Bitmap to an unrelated type flash.display:Sprite.
So how do you print a bitmap without creating a Sprite?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我从未尝试过打印......但这可能会有所帮助:
pJob.addPage 需要一个精灵..因此请为其提供一个像这样包装位图的精灵:
我希望它能工作
I never tried printing... but this could help:
pJob.addPage is expecting a sprite.. so provide it with one that's wraping your bitmap like this:
I hope it works