draw a canvas to another canvas

From: http://www.jamesward.org/wordpress/2006/08/16/flex-paint-flex-display-object-to-png/#more-66
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:VBox width="300" height="300">
<mx:Canvas id="c" width="500" height="500" backgroundColor="#ffffff">
<mx:Label left="0" top="0" text="top left"/>
<mx:Label left="0" bottom="0" text="bottom left"/>
<mx:Label right="0" top="0" text="top right"/>
<mx:Label right="0" bottom="0" text="bottom right"/>
</mx:Canvas>
</mx:VBox>
<mx:Canvas id="p" width="500" height="500"/>
<mx:Button label="duplicate canvas">
<mx:click>
import flash.display.BitmapData;
var bd:BitmapData = new BitmapData(c.width,c.height);
bd.draw(c);
p.graphics.clear();
p.graphics.beginBitmapFill(bd);
p.graphics.drawRect(0, 0, c.width, c.height);
</mx:click>
</mx:Button>
</mx:Application>

Share

0 条评论

留下评论