如何显示Flash和PHP之间数据传输的进度? 下面是我用来通过PHP上传base64编码图像的AS3代码。
var scriptLoader:URLLoader = new URLLoader();
var scriptVars:URLVariables = new URLVariables();
var scriptRequest:URLRequest = new URLRequest("https://www.example.com/sendit.php");
var imagedata = Base64.encode(mybitmap);
scriptVars.theimage = imagedata
scriptRequest.method = URLRequestMethod.POST;
scriptRequest.data = scriptVars;
scriptLoader.load(scriptRequest);
(服务器正在运行PHP版本5.3.10)
答案 0 :(得分:0)
您可以在ScriptRequest上为ProgressEvent.PROGRESS添加事件侦听器,以监视加载完成情况。事件回调将包含要监视的bytesLoaded和bytesTotal。
ProgressEvent参考: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/ProgressEvent.html
scriptRequest.addEventListener(ProgressEvent.PROGRESS, onProgress);
function onProgress(e:ProgressEvent):void {
trace(e.bytesLoaded + " of " + e.bytesTotal);
}