您可以使用BitmapData
。
類成員:
// flip vertically and shift by 100 (insert your canvas size)
private var reflect:Matrix = new Matrix(1, 0, 0, -1, 0, 100);
// instanciate BitmapData with 100x100 size (insert your canvas size),
// filled with black but with 100% transparancy, it's an
// ARGB value (0 == 0x00000000)
private var reflectionData:BitmapData = new BitmapData(100, 100, true, 0);
private var reflection:Bitmap = new Bitmap(reflectionData);
INIT:
// you might want to draw canvas already on startup
reflectionData.draw(canvas, reflect);
reflection.x = canvas.x;
reflection.y = canvas.y + canvas.height;
addChild(reflection);
上動畫/重繪
// clear to transparency
reflectionData.fillRect(reflectionData.rect, 0);
// draw the current canvas with matrix applied
reflectionData.draw(canvas, reflect);
的addChild(畫布)增加了帆布,然後reflection.addChild(畫布)去除畫布和從它的前一個父母,並將其添加到反射。你需要一個畫布的副本。最簡單的解決方案是使用BitmapData將畫布的內容繪製到其中,如果您願意,可以應用變換矩陣將其翻轉並遮罩。幸運的是,您可以使用[Adobe Devnet上的Reflection類](http://www.adobe.com/devnet/flash/articles/reflect_class_as3.html)。 – 2011-06-03 10:34:17
@George,你在我發佈我的答案之前寫了那條評論!應該把它放到一個答案我woulda upvoted :)。 – 2011-06-03 10:36:00
@Ascension完成。這就是我已經在努力的。 :) – Matthias 2011-06-03 10:42:18