R – flex: take screenshot from loaded swf from swfloader
apache-flexswfloader
can i save a screenshot from a loaded swf using the SWFLoader class ?
Best Answer
In case the loaded swf is already in a desired state in swfLoader, you should be able to do this
var bitmapData:BitmapData =
new BitmapData(swfLoader.content.width, swfLoader.content.height);
bitmapData.draw(swfLoader);
var bitmap:Bitmap = new Bitmap(bitmapData);
var image:Image = new Image;
image.source = bitmap;
addChild(image);
This would add the resulting screen capture in the display list of your application. Of course, if you want to save it, you can take the bitmapData and encode it into PNG, for example. You can find plenty of tutorials for this. If you're using AIR you can simply save it on the user's disk. In case your app is on a web page, you probably need some server-side support for saving the image.
Dispatch an event from the loaded swf. Make sure the event bubbles if you sent it from nested views. Bubbling can be set through the bubbles property of the event.
Listen to the event from your main application. I think you should be able to do that on the content property of the SWFLoader instance.
Best Answer
In case the loaded swf is already in a desired state in swfLoader, you should be able to do this
This would add the resulting screen capture in the display list of your application. Of course, if you want to save it, you can take the bitmapData and encode it into PNG, for example. You can find plenty of tutorials for this. If you're using AIR you can simply save it on the user's disk. In case your app is on a web page, you probably need some server-side support for saving the image.