AS2:加载框架之前等待动作脚本运行
我有一个脚本,需要大量内容并在舞台上构建 1000 个 MovieClip,进行大量绘图等。由于帧首次加载时需要大量工作,有时可能会延迟一两秒。
用户使用应用程序的次数越多,这个时间可能会越来越长(需要吸收和构建的数据就越多)。
我向您提出的问题是,如何确保框架在构建之前不会显示(提供加载图像或其他内容)?我不希望用户看到页面的骨架,然后所有内容都在一两秒后出现。
I have a script that takes lots of content and builds 1000s of MovieClips on the stage, does lots of drawing etc. Due to the high amount of work needed when the frame first loads this can sometimes be delayed by a second or two.
The more the user uses the application the longer and longer this is likely to be (more data to siphon through and build).
My question to you is how do I make sure the frame doesn't show (serve a loading image or something) until it is built? I don't want the user to see the skeleton of the page and then everything appear a second or two later.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们的做法是:
第 1 帧是加载帧。它只是不断地轮询进度(onEnterFrame),直到它足够“完整”以移至所需的帧。在您的情况下,您可能正在测试是否已实例化足够的对象,在我们的情况下,测试的是加载的帧是否足够高。
我们经常在第一帧中放置一个“加载图形”。除此之外,我们还有“我准备好继续前进了吗?”。最近,我们的装载机只有一个继续旋转的圆圈。
附带说明:如果您使用 AS3 加载程序,请等到一切都完全准备好。有一年复活节,装载半挂状态让我一直工作到凌晨 3 点。我不高兴。
The way we do it:
Frame 1 is a loading frame. It simply continually polls progress (onEnterFrame) until it is sufficiently "complete" to move on to the frame that is needed. In your case, it might be that you're testing to see if you've instantiated enough objects, in our case it was whether framesloaded was sufficiently high.
We often put a "loading graphic" in frame 1. Other than that we have the "am I ready to finally move on yet?". Most recently our loader just had a circle which continued rotating.
As a side note: wait until everything is completely ready if you're working with an AS3 loader. Loading half-cocked left me working until 3 AM on Easter one year. I was not happy.