我有一个按钮,这个按钮的相关功能是打印舞台的某些部分。问题是,在打印后,该特定部分作为图像出现在舞台顶部。我已经使用 removechild 从舞台上删除了精灵,但我认为问题出在其他地方。如果有人可以帮助我,我将不胜感激。
var printJob:PrintJob = new PrintJob();
var options:PrintJobOptions = new PrintJobOptions();
options.printAsBitmap = false;
printJob.start();
var bitmapData:BitmapData = new BitmapData(stage.stageWidth,stage.stageHeight);
bitmapData.draw(stage);
var bitmapDataA:BitmapData = new BitmapData(700,460);
bitmapDataA.copyPixels(bitmapData, new Rectangle(0, 270, 700, 800), new Point(0, 0));
//convert bitmapdata to bitmap to sprite
var screenShot:Bitmap = new Bitmap(bitmapDataA);
addChild(screenShot);
var axSprite:Sprite = new Sprite();
axSprite = (bitmapToSprite(screenShot));
//========== printjob bug fix - prevent blank pages: ==========
axSprite.x = 2000;//keep it hidden to the side of the stage
//axSprite.y = 2000;
stage.addChild(axSprite);
//add to stage - prevents blank pages;
//=============================================================
var myScale:Number;
myScale = Math.min(printJob.pageWidth/axSprite.width, printJob.pageHeight/axSprite.height);
axSprite.scaleX = axSprite.scaleY = myScale;
var printArea:Rectangle = new Rectangle(0,0, printJob.pageWidth/myScale, printJob.pageHeight/myScale);
printJob.addPage(axSprite, printArea, options);
printJob.send();
stage.removeChild(axSprite);
axSprite = null;
printJob = null;