I have to convert a MovieClip to ByteArray and send it to php using the POST method. The person handling php says that only ByteArray needs to be send and conversion to JPG and PNG can be done from PHP side. When I built the option for saving on the local machine the following steps were used.
- Converting to Bitmapdata
- Using JPGEncoder and PNGEncoder on the Bitmapdata
- Then assiging to byte array variable.
So in this case different byte arrays were used for saving in case of JPG and PNG and it worked.
I found the code to convert movieclip to bytearray in Stackoverflow itself
AS3: Export a MovieClip or Canvas to swf
var buffer:ByteArray = new ByteArray();
buffer.writeObject(MOVIE_CLIP_HERE);
buffer.position = 0;
buffer.writeBytes(...);
What should be the parameter of writeBytes function of buffer object. Assume that the name of the movieclip is canvas_mc.
I have figured out the php part already. Thanks in advance.