ActionScript 预加载器更详细的百分比

发布于 2024-11-12 09:59:55 字数 348 浏览 4 评论 0原文

我正在为我正在构建的闪存应用程序构建预加载器。我正在寻找一种方法,从所有预加载器用来跟踪下载进度的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

紅太極 2024-11-19 09:59:55

这是没有意义的 - 除非您的互联网连接一次加载恰好 1% 文件。

发生的情况是,收到每个新数据包后,根据您的下载速度,它可能是任意大小(假设在 200 到 230kb 之间)。每次收到其中一个事件时都会调度 ProgressEvent.PROGRESS ,并按照您的预期添加到加载的总百分比中。

基本上,假设我们正在加载 1000kb 文件,而您的下载速度为 100-150kbps

每次发送 ProgressEvent.PROGRESS 时调用的函数中的每个 trace() 都将在收到新数据包时运行,因此:

已加载 100kb - 总共 100 个 - 痕迹
10
已加载 120kb - 总共 220 -
痕迹 22
150kb 已加载 - 370
总计 - 痕迹 37

等。

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 of ProgressEvent.PROGRESS will be run when a new packet has been received, so:

100kb loaded - 100 total - traces
10
120kb loaded - 220 total -
traces 22
150kb loaded - 370
total - traces 37

Etc.

吃不饱 2024-11-19 09:59:55

您到底需要这些百分比做什么?没有办法强制 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.

送你一个梦 2024-11-19 09:59:55

你的帧速率有多快?可能是它设置得太低,导致进度刷新频率降低。我会尝试提高你的帧速率或主要电影。

另一种常见的方法是通过补间两个间隔之间的值来模拟它,因此它看起来更平滑。但这听起来不太像您想要实现的目标。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文