Can anyone tell me how to retrieve the response from the php file im posting to and then send them to a js function please.
I also have a animated gif image in the script which doesnt show the animation. Can anyone get this working too?
the php response is in this format variable1=blabla&varaibale2=blabla
function sendPixelData(e:MouseEvent):void {
capture_mc.visible = false;
send_mc.visible = false;
txtReturn.htmlText="Uploading Image......<img src="loading.gif" /><br/> Please Wait!";
var output:String = "";
var col = "";
for (var i:Number=0; i<bitmapData.height; i++) {
for (var j:Number=0; j<bitmapData.width; j++) {
col = bitmapData.getPixel(j,i).toString(16);
// In some cases, the color will be truncated (e.g. "00FF00" becomes "FF00")
// so we are adding the missing zeros.
while (col.length<6) {
col = "0" + col;
}
output += col;
}
}
var request:URLRequest = new URLRequest("GetPixelData.php");
var variables:URLVariables = new URLVariables();
var myURLLoader:URLLoader = new URLLoader();
variables.pixels=output;// all image pixel
//trace("output" + output)
variables.width=videoPreviewWidth;// video width
variables.height=videoPreviewHeight;// video height
request.data=variables;
request.method=URLRequestMethod.POST;
myURLLoader.addEventListener ("complete", onC);
myURLLoader.load (request);
function onC (e) {
var result:String =
ExternalInterface.call( "redirectToURL(send variables here)" );
trace ("save complete");
}
}
The result from PHP is stored in the data property of the URLLoader, so to retrieve it use:
function onC (e:Event) {
var result:String = String(e.target.data);
...etc
For part 2 of your question, Flash doesnt support gif file format - you need to use jpg or png.
BTW, dont use strings for event types - use the event type constant, eg:
myURLLoader.addEventListener (Event.COMPLETE, onC);