I'm currently creating a series of as3 / PHP classes that upload - encode + download images.
Anyone know if there's a way to report progress while posting a ByteArray to the server?
the ProgressEvent is not working - at least not in the case of uploadi开发者_运维知识库ng a ByteArray -
it reports progress only after it's been uploadedhere's a stripped version of the code I'm using ...
urlLoader=new URLLoader;
urlLoader.dataFormat=URLLoaderDataFormat.BINARY;
urlLoader.addEventListener(ProgressEvent.PROGRESS,progressHandler);
//
function progressHandler(e:ProgressEvent):void {
trace(e.bytesLoaded/e.bytesTotal);
}
thanks -MW
Are you using an URLLoader to send it? You should beable to add a ProgressEvent listener to it.
EDIT: You might need to send data back from PHP, see here: Grab a ProgressEvent from a POST upload in as3
http://www.ibm.com/developerworks/library/os-php-v525/index.html
URLLoader, while it supports sending data to the server, was designed for downloading data. The ProgressEvents are fired only as data from the server is received. In the case of an upload, this means that all the ProgressEvents will occur after the upload is already finished.
If the file is off the user's hard drive, you might be able to use the FileReference class to upload it to the server instead, which does dispatch ProgressEvents as the upload progresses (and not just the download).
Also, if you are using Flash Player 10, then it is possible to load a file off of the user's computer directly into Flash, manipulate it, then save it back out again (or just use it in Flash) without involving the server. This may not be an option, however, if you are encoding images from/into a format that Flash (or 3rd-party ActionScript libraries) cannot understand.
You should look into this ActionScript 3 library: http://code.google.com/p/as3httpclient/
It may solve your problem. I'm currently using it on a project and its been great.
精彩评论