2
我有一個按鈕,此按鈕的相關功能具有打印舞臺某些部分的作業。問題在於,打印之後,該特定部分作爲圖像出現在舞臺的頂部。我已經使用removechild從舞臺上刪除精靈,但我認爲問題在其他地方。 如果有人能幫助我,我將不勝感激。Actionscript 3,執行打印作業後的文件更改
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;