如何确定“initProgress”的总数 来自预加载器的事件?
闪存预加载器发出 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不要太担心总数,根据我的经验,这应该发生得很快,因此没有必要完全准确。 如果您做了一些测试,发现它计数到了大约 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.
mx.preloaders.DownloadProgressBar
类使用看似任意的值 12:我不知道他们从哪里获得该值,但它似乎对 Adobe 来说工作得足够好......?
The
mx.preloaders.DownloadProgressBar
class uses the seemingly aribtrary value of 12:I don't know where they get that value, but it seems to work well enough for Adobe...?
也许每次组件初始化时都会触发该事件?
如果您告诉我们您到底想做什么,也许会有帮助。 我们可以尝试寻找替代解决方案。
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.
您应该将进度条基于 bytesLoaded / bytesTotal,而不是基于调用处理程序的次数。
例如:
然后,在您的处理程序中,执行如下操作:
You should base your progress bar on the bytesLoaded / bytesTotal, not on the number of times the handler is called.
For example:
Then, in your handler, do something like this: