使用flash.display.Loader进度指示器 [英] Progress indicator using flash.display.Loader

查看:199
本文介绍了使用flash.display.Loader进度指示器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要做一个简单的进度指示器,同时在后台加载图像。我使用的是什么似乎是标准的方式flash.display.Loader类。问题是,即使我可以看到flash.display.LoaderInfo触发使用ProgressEvent.PROGRESS在使用跟踪,动态更新的文字(或任何其他图形对象)定期更新一次当加载完成。它看起来像如果显示更新排队并造成只有一个更新在末端。这是函数的简化版本,它启动装载

I need to do a simple progress indicator while loading an image on background. I’m using the flash.display.Loader class in what seems to be the standard way. The problem is that even though I can see that flash.display.LoaderInfo fires the ProgressEvent.PROGRESS at regular intervals using tracing, a dynamically updated text (or any other graphics object) is updated only once when the loading finishes. It looks like if the display update queued and caused only one update at the end. This is a simplified version of the function which initiates the loading:

public function init()
{
    var loader : Loader = new Loader(); 
    var request : URLRequest = new URLRequest(this.imageSrc); 
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
    loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, updateProgress);
    loader.load(request);
}

和这是事件处理程序:

private function updateProgress(event : ProgressEvent) : void
{
    progressIndicator.text = event.bytesLoaded + " / " + event.bytesTotal;
    trace(event.bytesLoaded + " / " + event.bytesTotal);
}

我的可能是一个基本的问题深表歉意。我不使用Flash非常频繁。但在我看来,我做一个明智的和直观的事情。它一定是有101闪存陷阱。

I apologize for probably an elementary question. I don’t use Flash very often. But it seems to me that I’m doing a sensible and intuitive thing. It must be some 101 Flash pitfall.

推荐答案

看来,答案是相当沉闷。我的问题是,在开发工作中,我用的是独立的Flash播放器(我双击SWF文件或运行它在Adove Flash CS3中)。这个问题显然是,图像已经被缓存导致Event.PROGRESS几个快速连续调用。当我后来试图在浏览器中的SWF文件,并​​定期清理浏览器缓存,加载图像按预期的方式每次。

It seems that the answer is rather dull. My problem was that during the development work, I was using the standalone Flash player (I double clicked on the SWF file or ran it in Adove Flash CS3). The problem apparently was that the images were already cached which resulted in several quick successive invocations of Event.PROGRESS. When I later tried the SWF file in a browser and regularly cleaned the browser cache, the images were loaded as expected every time.

我猜令人费解的事情是,即使在图像缓存,我有几个Event.PROGRESS事件(约3左右),我认为这是非常粗粒度的问题而已。如果我测量事件之间的时间,我就可能已经发现越早发生了什么事情。

I guess the puzzling thing was that even though the images were cached, I got several Event.PROGRESS events (about 3 or so) and I assumed that it was just a matter of very coarse granularity. If I measured the time between the events, I would have probably discovered sooner what was going on.

这篇关于使用flash.display.Loader进度指示器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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