Is it possible to take a screenshot (dump image) of the Stage and save it to my web server?
A:
See http://stackoverflow.com/questions/746095/how-do-i-produce-a-screenshot-of-a-flash-swf-on-the-server.
ceejayoz
2009-06-03 19:49:45
+2
A:
This should do the trick:
var myBitmapData:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight);
myBitmapData.draw(stage);
(actually i'm not sure if you can do a draw() on the stage directly, you might need to do this on whatever is on top of your DisplayList instead)
Then use something like this code: http://henryjones.us/articles/using-the-as3-jpeg-encoder
var jpgEncoder:JPGEncoder = new JPGEncoder(85);
var jpgStream:ByteArray = jpgEncoder.encode(myBitmapData);
var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
var jpgURLRequest:URLRequest = new URLRequest("jpg_encoder_download.php?name=sketch.jpg");
jpgURLRequest.requestHeaders.push(header);
jpgURLRequest.method = URLRequestMethod.POST;
jpgURLRequest.data = jpgStream;
navigateToURL(jpgURLRequest, "_blank");
To send it to the server.
grapefrukt
2009-06-04 08:08:22