Flexモバイルアプリケーションを開発しているところですが、画像のアップロードの進行状況を表示する必要があります。
コードは次のとおりです。
protected function upload( ba:ByteArray, fileName:String = null ):void {
if( fileName == null ) {
var now:Date = new Date();
fileName = "IMG" + now.fullYear + now.month +now.day +
now.hours + now.minutes + now.seconds + ".jpg";
}
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.BINARY;
var wrapper:URLRequestWrapper = new URLRequestWrapper(ba, fileName, null, params);
wrapper.url = "http://www.the_url_to_upload.com/php_content/upload_image.php";
loader.addEventListener( Event.COMPLETE, completeImageHandler );
loader.addEventListener( ProgressEvent.PROGRESS, imageProgress);
loader.addEventListener(IOErrorEvent.IO_ERROR, errorImageUploading );
loader.load(wrapper.request);
}
private function imageProgress(evt:ProgressEvent):void {
var pcent:Number=Math.floor(evt.bytesLoaded/evt.bytesTotal*100);
label_upload.text = pcent+"%";
}
「label_upload」というラベルがあり、ファイルのアップロード時に進行状況のパーセンテージを表示する必要があります。
実際には、すべてが正常に機能しますが、何も変更されない進行状況イベントです。常に0%を表示します。
私は自分のせいを推測することはできません。
ありがとう。