R – yield control to child SWF’s

actionscript-3apache-flex

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.

Best Answer

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.

Related Topic