AsyncTask also in flash?

2019-04-11 11:29发布

问题:

i have develop one game size of 27mb,i load it in device & its performance are going to lower and some time its hang the device.there are much Media resource are used in this game.if i make it in android then i will handle with Asynctask and make some process in background and also make memory management but here i have develop game in flash with AS3 and use Adobe Air. so my question is :: is there any method like asynTask are stay in flash or any performance related thing by which i take precaution against poor performance?

Thanks
nik

回答1:

You should consider using Flash 11 and AIR 3 - the new version allow the execution of native code, so that you can use Flash and AIR for the UI and the animations while at the same time you can execute asynchronously some native threaded code that otherwise would have of been occupying the time in between frames. In the native code you can have all of the calculations that are not related to the UI - e.g. the AI logic.

A detailed tutorial is provided by Lee Brimelow on his blog - Two-Part Tutorial on Android Native Extensions



回答2:

As far as I know there's only two threads network thread and thread doing all other actions. Asynctask is about optimal using UI thread, so because of there's no separate UI thread in flash/AIR there could be no analogous tricks. As for other methods, I'm affraid there's no general answer.



回答3:

If you want to load assets asynchronously, you should use the URLLoader and Loader classes to load resources. They will load stuff in the background and throw an Event (Event.COMPLETE) when they are done.



回答4:

Here are some links on how to use PixelBender to do stuff like number crunching in a separate thread, I'm not sure it is supported on Android though, so you would have to look in to that further:

http://blogs.adobe.com/aharui/2008/01/threads_in_actionscript_3.html

Stack Overflow question, the answer by Ascension Systems:

Flash parallel programming



回答5:

You should read Optmizing performance for the Flash Platform help.adobe.com/en_US/as3/mobile/flashplatform_optimizing_content.pdf