繁体   English   中英

AS3-显示Flash和PHP之间的数据传输进度

[英]AS3 - Display data transfer progress between Flash and PHP

如何显示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)

您可以在scriptRequest上为ProgressEvent.PROGRESS添加事件侦听器,以监视加载完成。 事件回调将包含要监视的bytesLoaded和bytesTotal。

ProgressEvent参考: http : //help.adobe.com/zh_CN/FlashPlatform/reference/actionscript/3/flash/events/ProgressEvent.html

scriptRequest.addEventListener(ProgressEvent.PROGRESS, onProgress);

function onProgress(e:ProgressEvent):void {
   trace(e.bytesLoaded + " of " + e.bytesTotal);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM