【问题标题】:Actionscript 3, file changes after executing printjobActionscript 3,执行打印作业后文件更改
【发布时间】:2012-10-30 14:50:12
【问题描述】:

我有一个按钮,这个按钮的相关功能是打印舞台的某些部分。问题是,在打印后,该特定部分作为图像出现在舞台顶部。我已经使用 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;

【问题讨论】:

    标签: flash actionscript printing sprite stage


    【解决方案1】:

    您在此处将screenShot 实例添加到displayList

    //convert bitmapdata to bitmap to sprite
    var screenShot:Bitmap = new Bitmap(bitmapDataA);
    addChild(screenShot);
    var axSprite:Sprite = new Sprite();
    axSprite = (bitmapToSprite(screenShot));
    

    我不确定您为什么需要这样做,但如果需要,请确保稍后再次删除它:

    stage.removeChild(axSprite);
    removeChild(screenShot);
    axSprite = null;
    printJob = null;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-23
      • 1970-01-01
      • 2010-10-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多