如何确定“initProgress”的总数 来自预加载器的事件?

发布于 2024-07-13 09:33:32 字数 316 浏览 11 评论 0原文

闪存预加载器发出 FlexEvent.INIT_PROGRESS 事件来指示闪存应用程序初始化的进度。 但是,调度此事件的次数取决于应用程序本身。

我正在尝试确定这个数字,但在 Flex 文档中找不到答案,所以现在我只能进行实验。 更糟糕的是,在我看来,即使闪存文件未经修改,这个数字也会随时变化。

是否有一种编程方法可以至少给出这个值的估计?

编辑:我使用此信息在预加载器中显示进度条。 实际上,我显示了两个,一个是在下载程序时显示的,第二个是在初始化程序时显示的。

The flash preloader emits FlexEvent.INIT_PROGRESS events to signal the progress of the flash application initialization. However, the number of times this event is dispatched depends on the application itself.

I am trying to determine this number, but I couldn't find an answer in the Flex documentation, so right now I resort to experimentation. To make it worse, it appears to me that this number varies from time to time, even if the flash file is unmodified.

Is there a programmatic way to give at least an estimate on this value?

Edit: I'm using this information to display a progress bar in the preloader. Actually, I display two, one while downloading the program, and a second one while initializing it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

淡水深流 2024-07-20 09:33:33

不要太担心总数,根据我的经验,这应该发生得很快,因此没有必要完全准确。 如果您做了一些测试,发现它计数到了大约 14,那么只需手动将进度条设置为最大(比如 20)。用户仍然会看到进度条很快填满,因为它不会在屏幕上停留很长时间,没有人关心它是否完全准确。

Don't worry about the total number too much, in my experience this should happen so quickly that it's not necessary to be completely accurate. If you do a few tests, and find that it counts up to about 14, then just manually set your progress bar to have a maximum of say 20. The users will still see the bar filling up quickly, since it's not onscreen for very long, nobody cares if it's completely accurate.

橪书 2024-07-20 09:33:33

mx.preloaders.DownloadProgressBar 类使用看似任意的值 12:

private var _initProgressTotal:uint = 12;

// [...]

protected function initProgressHandler(event:Event):void
{
    // [...]

    var loaded:Number = 100 * _initProgressCount /
    (_initProgressTotal - _displayStartCount);

    // [...]
}

我不知道他们从哪里获得该值,但它似乎对 Adob​​e 来说工作得足​​够好......?

The mx.preloaders.DownloadProgressBar class uses the seemingly aribtrary value of 12:

private var _initProgressTotal:uint = 12;

// [...]

protected function initProgressHandler(event:Event):void
{
    // [...]

    var loaded:Number = 100 * _initProgressCount /
    (_initProgressTotal - _displayStartCount);

    // [...]
}

I don't know where they get that value, but it seems to work well enough for Adobe...?

深海里的那抹蓝 2024-07-20 09:33:33

也许每次组件初始化时都会触发该事件?

如果您告诉我们您到底想做什么,也许会有帮助。 我们可以尝试寻找替代解决方案。

Maybe that Event gets fired everytime a Component gets initialized?

Maybe it helps if you tell us, what exactly you want to do. We could try to find an alternative solution.

零崎曲识 2024-07-20 09:33:33

您应该将进度条基于 bytesLoaded / bytesTotal,而不是基于调用处理程序的次数。

例如:

preloader.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onPreloaderProgress);

然后,在您的处理程序中,执行如下操作:

function onPreloaderProgress(e:ProgressEvent):void
{
    progress = e.bytesLoaded / e.bytesTotal;
}

You should base your progress bar on the bytesLoaded / bytesTotal, not on the number of times the handler is called.

For example:

preloader.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onPreloaderProgress);

Then, in your handler, do something like this:

function onPreloaderProgress(e:ProgressEvent):void
{
    progress = e.bytesLoaded / e.bytesTotal;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文