我目前在打印多页文档时遇到了令人沮丧的问题。基本上,我在舞台上有一个movieclip(printArea),它包含几个元素,包括使用加载器组件,datagrid组件和其他一些元素加载的图像。AS3将影片剪辑化为Sprite以进行打印
此影片剪辑充当单个页面的模板;您调整选项,然后单击“添加页面”,然后再次更改为第二页,等等。我遇到的问题是将页面添加到数组中以便稍后使用addPage()进行循环。据我所知,精灵或影片剪辑最好传递给addPage。我觉得复制影片剪辑总是过于矫枉过正,然后用数据,大小和定位集重新初始化所有组件。由于我需要从一个实例建模的几个页面,因此我无法传递影片剪辑本身。有没有办法简单地光栅化影片剪辑,将其传递给addPage()?这是目前我已经找到了唯一的解决办法,但打印质量更是苦不堪言:提前
//So let's say I want to add the movie clip's current state to the array :
multiPages.push(duplicateMC(printArea));
function duplicateMC(mc)
{
var tempImg:BitmapData = new BitmapData(mc.width,mc.height);
tempImg.draw(mc);
var fullImg = new Bitmap(tempImg);
var newImg = DisplayConverter.bitmapToSprite(fullImg,true);
multiPages.push(newImg);
}
//DisplayConverter function in a seperate file (Snagged this online somewhere) :
public static function bitmapToSprite(bitmap:Bitmap, smoothing:Boolean = false):Sprite
{
var sprite:Sprite = new Sprite();
sprite.addChild(new Bitmap(bitmap.bitmapData.clone(), "auto", smoothing));
return sprite;
}
谢谢,这一直是一个巨大的痛苦,我一整天。
有没有你不能实例化一个新的'PrintArea'当'点击addPage',删除现有的一个从舞台和存储,在'multiPages'基准的原因是什么? –