2011-06-01 54 views
1

我知道在这个论坛上有类似的问题,但我试过发布的想法,但他们没有工作。在AS3中打印Movieclip(Flash CS3)

基本上我们试图打印一个包含用户绘制图形的动画片段。我们有一个用作画布的矩形,其中一些绘图可能在此画布之外。我们要做的是只打印画布中的内容,而不是以(0,0)开始。在打印之前,画布也需要调整大小以适合纸张。

我们想知道是否有人有解决方案吗?我们尝试了很多不同的东西,但事情总是被切断或者错误的尺寸,甚至不适当地延伸。

这是我们的超级乱码!

function startPrint(evnt: Event) { 
printJob = new PrintJob(); 
var xNumber:Number = allGraphic.x; //saving the original x-value of the movieclip 
var yNumber:Number = allGraphic.y; //saving y 
var wNumber:Number = allGraphic.width; //saving width 
var hNumber:Number = allGraphic.height; //saving height 
var rect:Rectangle = new Rectangle (0,0,0,0); //printArea 

var sucess = printJob.start(); 

if (sucess) { 
if (printJob.orientation == PrintJobOrientation.LANDSCAPE) { 
//allGraphic.rotation = 90; 
rect.x = 115; 
rect.y = 107; 
rect.width = 792; 
rect.height = 576; 
allGraphic.width = 792; 
allGraphic.height = 576; 
} //end if (landscape) 
      else { 
rect.x = 110; //x coor of the printArea rectangle 
rect.y = 85; //y coor 
rect.width = 875; //width of printArea 
rect.height = 475; // height of printArea 
allGraphic.width = allGraphic.width *(576/wNumber); //scale the movieclip width (with the drawing) 
allGraphic.height = allGraphic.height * (396/hNumber); // height scaling  
}//end else 

printJob.addPage (allGraphic, rect); 
}//end 

if success 

//reset allGraphic back to original size 
allGraphic.x = xNumber; 
allGraphic.y = yNumber; 
allGraphic.width = wNumber; 
allGraphic.height = hNumber; 
} 

回答

1

问题出在使用allGraphic.width。这是绘图区域的完整宽度,包括负面和正面重叠。您还应该使用scaleXscaleY,而不是设置缩放的宽度和高度(回去只是拨打scaleX = scaleY = 1)。

我会建议使用画布的固定尺寸,用户可以为您的比例计算绘制。您也可以应用与您画布大小的mask“剪切”重叠的图纸。