ensuring buttons stay responsive during intensive task

I’m using director class for my menu transitions.

If the user pushes the ‘process menu button’ a maths calculation is performed which takes 5 seconds or more. During that time the back button remains unresponsive. It only works again after the calculation is finished.

Is there a way for the button to remain responsive during the calculation ? It would be nice if the user could push “back” to go back to the main menu (and interrupt the calculation) [import]uid: 97524 topic_id: 19373 reply_id: 319373[/import]

We’d have to see some code, 5 seconds is a long time, what kind of calculation is this?

Peach :slight_smile: [import]uid: 52491 topic_id: 19373 reply_id: 74837[/import]

Hi Peach!

FYI it’s not a game or anything.

I’m performing a FOR DO loop through 10,000 rows of Table data, performing a complex number calc on each?

Just wondering if it’s possible to listen for button events during that ?

[import]uid: 97524 topic_id: 19373 reply_id: 74900[/import]

You could have an enterFrame listener and split your 10,000 iterations into manageable chunks to be performed each frame, giving the user the opportunity to push the back button and interrupt the processing.

[import]uid: 93133 topic_id: 19373 reply_id: 74903[/import]

hmmm, Ok - I could try that.

[import]uid: 97524 topic_id: 19373 reply_id: 74916[/import]

You might be able to utilize coroutines to help you split your computation up without a major refactor of your code. Add coroutine.yield between each of your computation calls, and put a coroutine.resume in the enterFrame while you are doing this.
[import]uid: 7563 topic_id: 19373 reply_id: 74931[/import]