简体   繁体   English

在 Flash/AS3 中使用 Loader.load() function 时是否存在挂起或延迟?

[英]Is there a hang or lag when using the Loader.load() function in Flash/AS3?

I have created a simple list of images that are to be reloaded every 60 seconds.我创建了一个简单的图像列表,每 60 秒重新加载一次。 However, I have noticed that when the reloading process begins, Flash seems to hang or at least doesn't accept/remember any mouse input at all.但是,我注意到当重新加载过程开始时,Flash 似乎挂起,或者至少根本不接受/记住任何鼠标输入。

Specifically, while it's supposedly frozen I try click a button to perform it's usual function, which at the moment is just showing the mouse down state, but it doesn't register the click until afte the supposed freeze is over.具体来说,虽然它应该被冻结,但我尝试单击一个按钮来执行它通常的 function,此时它只是显示鼠标向下 state,但它不会注册点击,直到假设的冻结结束之后。 Which results in me having to click again.这导致我不得不再次点击。

I really need to know, if I am loading say 5 small png images (calling load() 5 times in a loop) would this cause Flash to hang and ignore any mouse input or am I talking crazy and should be looking elsewhere for the problem.我真的需要知道,如果我正在加载说 5 个小 png 图像(循环调用load() 5 次) ,这会导致 Flash 挂起并忽略任何鼠标输入,还是我在说疯了,应该在别处寻找问题.

I understand Flash isn't multi-threaded but surely calling load() doesn't cause the whole application to just shut itself off for a 100-200 milliseconds?我知道 Flash 不是多线程的,但肯定调用load()不会导致整个应用程序自行关闭 100-200 毫秒?

Any input is greatly appreciated, thank you.非常感谢任何输入,谢谢。

In response to your comment:回应您的评论:

Can't give anymore definite proof other than to say that the Loader object actually loads a swf or some type of display object and then flash internally modifies the binary data, then internally parses the SWF or bitmap type and renders it to the.content display object within the Loader object. Can't give anymore definite proof other than to say that the Loader object actually loads a swf or some type of display object and then flash internally modifies the binary data, then internally parses the SWF or bitmap type and renders it to the.content display加载程序 object 内的 object。 Nevermind dispatching the URL request that fetches the binary data before all this.没关系在这之前发送获取二进制数据的 URL 请求。 There is a lot going on in the background of the loader object.加载程序 object 的后台发生了很多事情。 If you want proof about the modification of the binary data just load an image, then copy the bytes out of the loader and save it somewhere.如果您想证明二进制数据的修改,只需加载图像,然后将字节从加载器中复制出来并将其保存在某处。 Then compare against the original data.然后与原始数据进行比较。 You'll see the modification there and in fact if you save the output bytes back to an image and try to open it with an image viewer, it won't work this is also proof of the modification.您将在那里看到修改,事实上,如果您将 output 字节保存回图像并尝试使用图像查看器打开它,它将无法正常工作,这也是修改的证明。 Other than that, you could post a link to the SWF and have others here test it to confirm the same thing happens to them, which I'm sure it will.除此之外,您可以发布一个指向 SWF 的链接,并让其他人在这里测试它以确认同样的事情发生在他们身上,我相信它会发生。 That's about the most amount of proof you're gonna get since any code related to the Loader or display objects is closed source and not included in the Tamarin project, the open source portion of the flash VM.这大约是您将获得的最多证据,因为任何与加载器或显示对象相关的代码都是封闭源代码,并且不包含在 Tamarin 项目中,这是 flash VM 的开源部分。

Regarding freezing — read about LoaderContext#imageDecodingPolicy and see here http://www.bytearray.org/?p=2931关于冻结 - 阅读 LoaderContext#imageDecodingPolicy 并在此处查看http://www.bytearray.org/?p=2931

To answer my own question, no there is no lag or hang.要回答我自己的问题,不,没有滞后或挂起。 Flash manages to handle everything nicely it just turns out that you should watch out when using MouseEvent.CLICK because if you swap the image object during a reload after you have done a mousedown but before a mouseup, flash won't dispatch the click event as you haven't caused a mousedown and mouseup on the same object. Flash 设法很好地处理了所有事情,事实证明,在使用MouseEvent.CLICK时应该小心,因为如果在完成 mousedown 之后但在 mouseup 之前重新加载期间交换图像 object,ZA394012722221B3008AA789 不会将 click 事件调度为 1您没有在同一个 object 上造成 mousedown 和 mouseup。 Which apparantly made me think there was a lag as it seemed Flash didn't register my mouse click.这显然让我觉得有一个滞后,因为 Flash 似乎没有注册我的鼠标点击。

Thanks to all that tried to resolve the issue.感谢所有试图解决问题的人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM