ActionScript 预加载器更详细的百分比
我正在为我正在构建的闪存应用程序构建预加载器。我正在寻找一种方法,从所有预加载器用来跟踪下载进度的 ProgressEvent.PROGRESS
中获取更详细的百分比。当我对小文件的加载器百分比运行 trace()
语句时,我的输出窗口显示如下内容:
4
8
13
17
23 etc...
我正在寻找一种能够更密切地监视此进度的方法,因此我获取1、2、3等...
。如果数字重复,那没关系。我的预加载器的部分内容依赖于这些值,因此,如果能够在不跳过整数的情况下从 1 到 100 获取它们,那就太好了。
感谢您抽出时间。
I am building a preloader for a flash application I am building. I am looking for a way to gain more detailed percentages from the ProgressEvent.PROGRESS
that all preloaders use to track downloading progress. When I run a trace()
statement on the loader percentages for a small file, my output window displays something like this:
4
8
13
17
23 etc...
I am looking for a way to be able to monitor this progress more closely, so I get 1, 2, 3, etc...
. If numbers are repeated, that is okay. Parts of my preloader rely on these values, and thus, it would be great to be able to get them from 1 - 100 with no skipped whole numbers.
Thank you for your time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是没有意义的 - 除非您的互联网连接一次加载恰好 1% 文件。
发生的情况是,收到每个新数据包后,根据您的下载速度,它可能是任意大小(假设在 200 到 230kb 之间)。每次收到其中一个事件时都会调度
ProgressEvent.PROGRESS
,并按照您的预期添加到加载的总百分比中。基本上,假设我们正在加载 1000kb 文件,而您的下载速度为 100-150kbps。
每次发送
ProgressEvent.PROGRESS
时调用的函数中的每个trace()
都将在收到新数据包时运行,因此:等。
This doesn't make sense - unless your internet connection loaded exactly 1% of the file at a time.
What's happening is that after each new packet is received, it could be any size based on your download speed (let's say between 200 and 230kb).
ProgressEvent.PROGRESS
is dispatched each time one of these is received, adding to the total percentage loaded as you would expect.So basically, let's say we're loading a 1000kb file, and your download speed is 100-150kbps.
Each
trace()
in your function called on each dispatch ofProgressEvent.PROGRESS
will be run when a new packet has been received, so:Etc.
您到底需要这些百分比做什么?没有办法强制 URLLoader 为您提供每 1% 更新一次的信息,但您可以伪造它。
如果你想估计你的下载速度,你可以使用 getTimer 获取时间,并在每次收到进度事件时从 ProgressEvent 获取到目前为止下载的数量;一旦获得,您就可以比较新旧值并获得下载速度的近似值。
您可以做类似的事情来平滑进度条,一旦您有了下载速率,您就可以发布您的进度条,并在每帧上获得一个小的更新,并在每次获得 ProgressEvent 时获得更准确的更新。
What exactly do you need these percentages for? There's no ways to force URLLoader to give you something like an update on every 1% but you can fake it.
If you want to estimate your download speed you can get the time with getTimer and the amount downloaded so far from the ProgressEvent every time you get a progress event; once you have that you can compare the new vs. old values and get an approximation of your download speed.
You can do a similar thing smooth out a progress bar, once you have a download rate you can tweet your progress bar and get a small update every frame and a more accurate update every time you get a ProgressEvent.
你的帧速率有多快?可能是它设置得太低,导致进度刷新频率降低。我会尝试提高你的帧速率或主要电影。
另一种常见的方法是通过补间两个间隔之间的值来模拟它,因此它看起来更平滑。但这听起来不太像您想要实现的目标。
How fast is your framerate? It could be that it's set too low, causing the progress to refresh less often. I'd try increasing your framerate or the main movie.
Another common way is to simulate it by tweening values between the two intervals, so it looks smoother. But it doesn't quite sound like what you're trying to achieve.