开发者

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. However, I have noticed that when the reloading process begins, Flash seems to hang or at least doesn't accept/remember any mou开发者_如何学Pythonse input at all.

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. 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.

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?

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. Nevermind dispatching the URL request that fetches the binary data before all this. There is a lot going on in the background of the loader 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. 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. 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.


Regarding freezing — read about LoaderContext#imageDecodingPolicy and see here 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. Which apparantly made me think there was a lag as it seemed Flash didn't register my mouse click.

Thanks to all that tried to resolve the issue.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜