the NativeApplication class has an Event.USER_IDLE event you can use to detect when (and for how long using Event.USER_PRESENT) your app has been idled.
and, you can prevent idle mode (on some systems) by using
NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;
in any case, check the NativeApplication class for all sorts of things you can do to control how your app behaves and is behaving when it's running.
I have used these lines:
private function exiting(e:Event):void
textBox.text = "Shake!";
application.systemIdleMode = SystemIdleMode.NORMAL;
But it doesn't put the words back in the text box.