Reputation: 33
I have a Flash 10 program that locks up when running on a device, such as a netbook, that has a weak processor. Specifically, it goes into a state where it is doing very heavy processing within an ENTER_FRAME event handler following a mouse down event, and expects to stop doing this processing following a mouse up event. The problem is that, since there is no idle time left over following the frame event handlers, the mouse up event is never received, and consequently the process locks up in what amounts to an infinite loop. Yes I can do things like lower the frame rate and do what I can to reduce the processing taking place in each frame, but is there some iron clad way to break out of this? Is there some way to detect that no idle time exists? Or is there a way to force receipt of the interactive mouse events? Or could I, within the ENTER_FRAME code, detect the state of the mouse, up or down, without getting a mouse event?
Upvotes: 1
Views: 122
Reputation: 22604
Unfortunately, there is no threading and no "real" multitasking in Flash.
But try Alex Harui's PseudoThread implementation. It helps you to divide operations with heavy CPU usage into smaller parts, which are executed "in between" frame updates.
Upvotes: 1
Reputation: 8406
If Flash is dropping mouse events, there isn't any variable you can watch to track it yourself. The variables you would watch for mouse data depend on the same events.
You should update your algorithm to break its processing into smaller, repeatable chunks. MOUSE_DOWN should set a flag that causes this algorithm to process a few chunks each ENTER_FRAME, until MOUSE_UP clears the flag. Ideally, your algorithm would keep track of the frames per second and adjust the amount of work it does per frame to keep the FPS at a reasonable value.
Upvotes: 0