2011-10-06 61 views

回答

2

不,您必須將圖表添加到顯示列表中。

必須將A DisplayObject添加到顯示列表中,以便能夠將其呈現爲位圖(即將其打印出來或發送給PDF)。

內部AlivePDF使用BitmapData.draw(...); method,它要求該對象位於顯示列表中並且具有visible=true才能被渲染。

如果您不希望圖表在您生成PDF(或打印)時出現在舞臺上,那麼您可以將圖表添加到父容器並隱藏父容器。

這裏是你如何能做到這樣的例子:

var box:VBox = new VBox(); 
// Hide the parent, not the chart. 
// If you set chart.visible = false then it won't show up in the PDF. 
box.visible = false; 
box.addChild(chart); 
addChild(box); 

// You might need to force validation here so the chart has the correct size. 
box.validateNow(); 

// Add chart to PDF. 
pdf.addImage(chart); 

// TODO: Clean up your display items here. 
box.removeChild(chart); 
removeChild(box); 
box = null; 
+0

謝謝你,我喜歡這個主意。這個變化對我有效。 :) – Mino