A flash project I’m currently working on requires me to take a series of screenshots of the stage and upload those screenshots to a server. I’ve written the AS3 code pasted below to send the screenshots (converted to jpegs) to a php processing script (imageprocess.php).
for (var i:int=0; i<sourceArray.length; i++)
{
var jpgEncoder:JPGEncoder = new JPGEncoder(10);
var jpgStream:ByteArray = jpgEncoder.encode(sourceArray[i]);
var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
var jpgURLRequest:URLRequest = new URLRequest("imageprocess.php?name=drawing" + i +".jpg");
jpgURLRequest.requestHeaders.push(header);
jpgURLRequest.method = URLRequestMethod.POST;
jpgURLRequest.data = jpgStream;
navigateToURL(jpgURLRequest, "_blank"); //switch to ExternalInterface.call("someJS")
}
Unfortunately, I’ve discovered that navigateToURL can only function once per frame (http://www.actionscript.org/forums/showthread.php3?t=250594). It looks like I’ll have to use ExternalInterface.call plus some Javascript to upload multiple screenshots, but I’m not sure what this Javascript code would look like. Would anyone be kind enough to provide some example JS which could take each of the screenshots I convert and send them to a php file? I’d really appreciate any and all advice.
URLLoader might solve your problem. Haven’t use navigatetourl for uploading, really interesting.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLLoader.html