图像使用URLLoader AS3上传进度 [英] Image Upload progress using URLLoader AS3

查看:217
本文介绍了图像使用URLLoader AS3上传进度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Flash上​​的图片上传器。我使用FileReference.browse来浏览图像,然后将图像的大小调整为1000 x 1000像素,如果图像非常大,然后上传到服务器。我想显示进度条的图像上传进度。

我使用URLLoader发送调整大小的图像的二进制数据,但URLLoader ProgressEvent不工作的方式应该工作。只有在图像完成上传后才会触发,而不是显示中间进度。 FileReference上的ProgressEvent完美地工作,以显示中间图像上传进度。

有没有办法使用URLLoader显示上传进度?或

我们可以使用FileReference来加载修改后的图像,然后调用FileReference.upload,这样就可以显示实际的进度条。





更新1

但是我的问题是在使用FileReference之后调整浏览的图像.browse,我想上传调整大小的图片,而不是浏览后的FileReference对象中的原始图片。在这种情况下如何使用Filereference.upload? Filereference.upload将上传原始图像不是调整大小。任何想法,如何把调整大小的图像放入Filereference对象然后使用FileReference.upload。



更新2 :

无法在虚拟FileReference中设置数据,数据是只读属性。




Update 3

但是,从上面的链接可以看出,没有显示图片上传进度的问题:



我正在找一个正在寻找进度的事件,因为我们无法在向服务器发送数据的过程中显示任何进度。为上述问题的解决方案。 URLLoader可以很好的发布图片数据。

解决方案

URLLoader 的设置方式是:接收进度事件,直到加载完成,如 HERE 。您可能可以使用 URLStream ,而不是按照你的愿望来获取进度事件?我不确定URLStream的进度事件是否只会触发下载服务器的响应,或者如果他们将为整个事务启动(上传和下载),则文档似乎没有精确指定。


I am developing image uploader in Flash. I use FileReference.browse to browse image then resize this image to 1000 x 1000 px, if the image is very big and then upload to server. I want to show progressbar for the image upload progress.

I am usinng URLLoader to send binary data of the resized images, but ProgressEvent on URLLoader doesn't work the way it is supposed to work. It is fired only after the image is completed uploaded instead of showing intermediate progress. ProgressEvent on FileReference works perfectly to show intermediate image upload progress.

Is there a way to display upload progress using URLLoader? or

Can we use FileReference to load modified image and then call FileReference.upload, that way it will be possible to show actual progress bar.


Update 1 :
But my problem is that I am resizing the browsed image after using FileReference.browse, and I want to upload resized images, not the original picture in FileReference object after browse. How do I use Filereference.upload in this case? Filereference.upload will upload original image not the resized one. Any idea, how to put the resized image into Filereference object and then use FileReference.upload.


Update 2 :
Not able to set data in dummy FileReference, data is read-only property.


Update 3 :
But this has same problem of not showing image upload progress, from the above link:

"Unfortunately there is a problem getting progress event. We cant show any progress during sending data to server because flash doesn't support it"

I am exactly looking for a solution for the above issue. URLLoader works fine to post the image data.

解决方案

URLLoader is setup in such a way that it CANNOT receive progress events until the load is complete, as noted HERE in the docs. You might be able to use URLStream instead to get the progress event as you desire perhaps? I'm not sure if the progress events for URLStream only fire for download of the server's reponse, or if they will fire for the full transaction (upload & download), the docs don't seem to specify precisely.

这篇关于图像使用URLLoader AS3上传进度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆