I wanted to post the demo of the example I posted the other day as a video. It is using the new Query Graphics API we are introducing in Flash Player 11.6/AIR 3.6. Make sure you have Flash Player 11.6 and check the demo below. Just click anywhere to sample the graphical objects from the MovieClip then reconstruct it at runtime:
Here is the very simple code below, note that the API is now called readGraphicsData. You can download the full source code here:
package
{
import flash.display.IGraphicsData;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
[SWF(width="900", height="400", frameRate="30", backgroundColor="#FFFFFF")]
public class TestGrabby extends Sprite
{
private var b:BigBilbo = new BigBilbo();
private var v:Vector.<IGraphicsData>;
private var result:Vector.<IGraphicsData>;
private var copy:Sprite = new Sprite();
private var inc:int;
private var count:int;
public function TestGrabby()
{
b.scaleX = b.scaleY = .7;
copy.scaleX = copy.scaleY = .7;
b.x = 240;
b.y = 200;
addChild( b );
copy.x = 650;
copy.y = 200;
addChild ( copy );
stage.addEventListener(MouseEvent.CLICK, onClick);
}
private function onClick(e:MouseEvent):void
{
// reset
inc = 0;
stage.removeEventListener(Event.ENTER_FRAME, onFrame);
copy.graphics.clear();
// sample
v = b.graphics.readGraphicsData(true);
count = v.length;
result = new Vector.<IGraphicsData>(count, true);
stage.addEventListener(Event.ENTER_FRAME, onFrame);
}
private function onFrame (e:Event):void
{
if ( inc < count )
{
result[inc++] = v.shift();
copy.graphics.drawGraphicsData(result);
} else stage.removeEventListener(Event.ENTER_FRAME, onFrame);
}
}
}
I hope you guys will like it!




