简体   繁体   English

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

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

How to display the progress on a data transfer between Flash and PHP? 如何显示Flash和PHP之间的数据传输进度? Below is the AS3 code I'm using to upload a base64 encoded image through 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);

(Server is running PHP Version 5.3.10) (服务器正在运行PHP版本5.3.10)

You can add an event listener on scriptRequest for ProgressEvent.PROGRESS to monitor load completion. 您可以在scriptRequest上为ProgressEvent.PROGRESS添加事件侦听器,以监视加载完成。 The event callback will contain bytesLoaded and bytesTotal to monitor. 事件回调将包含要监视的bytesLoaded和bytesTotal。

ProgressEvent reference: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/ProgressEvent.html 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