How to save MovieClip using Flash+AS3+PHP

For example, I have a MovieClip that I can draw on. Next, I need to save the drawn image to .jpg or .bmp, it doesn’t matter.
How to do it?
It is not clear how you can make an image out of a movie.
I’m new to AS3 and the classes are huge.
If you somehow make an image out of the movie, you can transfer it to the server with the FileReference class, and there you can already save it with a php script.


Answer 1, authority 100%

Creating a bitmap based on a visual object, movie, sprite, graphics, that’s not the point

var b:BitmapData = new BitmapData(100, 100, true, 0x0);
b.draw(s);
var bitmap:Bitmap = new Bitmap(b);

save to server

var jpgSource:BitmapData = new BitmapData (sketch_mc.width, sketch_mc.height);
jpgSource.draw(sketch_mc);
var jpgEncoder:JPGEncoder = new JPGEncoder(85);
var jpgStream:ByteArray = jpgEncoder.encode(jpgSource);
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");

Google was heavily used, based on queries

adobe actionscript 3.0 save bitmap

adobe actionscript 3.0 bitmap from
sprite

second example uses lib – http://code.google.com/p/as3corelib/