views:

100

answers:

1

I have a function (call it funcX) that at certain times is being called on the enterFrame event. At those times it is extremely computation intensive and is for example using 70% of the available processing power of the computer or more.

Scroll events and other input events in the swf page are still being processed just fine. However, input events of child swf objects (i.e. those loaded by SWFLoader) are not being processed adequately while funcX is operating. So what can I call within funcX to yield time and precedence to whatever child SWF that needs it. callLater(funcX ...) in the enterFrame (or exitFrame) event of the parent SWF doesn't accomplish anything. I also don't want to slow down funcX if no child SWF has to process input events.

A: 

Unfortunately, there is no way to directly control this in Actionscript 3 – Here's a more authoritative resource on the subject. There are a couple of hacks you could try:

  • Before calling funcX, check with your child SWFs and make sure they don't need to process anything
  • split up your funcX function into several smaller functions if possible
  • consider optimizing your funcX function.

But really the bottom line is Actionscript 3 is not great for any sort of intensive computation.

Goose Bumper
Before calling funcX, check with your child SWFs and make sure they don't need to process anything Exactly how would I do that. These are just arbitrary SWF's, btw - I can't modify them.
Mark
[edit] "Before calling funcX, check with your child SWFs and make sure they don't need to process anything"Exactly how would I do that. These are just arbitrary SWF's, btw - I can't modify them.
Mark
What I was suggesting was have some function in the SWF that executes any functions that need to be executed before funcX is called...but obviously you can't do that if you can't change the SWFs.
Goose Bumper
As discussed in http://stackoverflow.com/questions/560474/flex-equivalent-of-processmessages-and-unresponsive-ui-during-long-loops, all that is really needed is a "message pump" - a function that can be called to yield control to process the message queue and then returns when the message queue is empty. This sort of feature would not be dependant on multiple threads, but nevertheless apparently does not exist in AS3. THere are some other fairly convoluted implementations of pseudo threads ("green threads") I'm looking at, but probably won't mess with,
Mark