How to determine when the system turns to sleep, or returns from sleep?

I was trying to find a way in Haxe/OpenFL to determine when the application gets into sleep mode, or returns from sleep.

In ActionScript NativeApplication (NativeApplication - Adobe ActionScript® 3 (AS3 ) API Reference), it suppose to dispatch events like suspend, userIdle, userPresent etc. However, I didn’t found any similar events in I not even sure if such events provides by openfl.desktop.NativeApplication or not, I didn’t seen any such reference in its documentation.

I’m mostly a newbie in Haxe/OpenFL, can someone help me to find a way out?


I looked things over, and I can confirm that these events have not yet been implemented in OpenFL. I don’t see anything like that in Lime’s API either. So it’s something that would need to be implemented at a low-level in C++ first, before being exposed to Haxe through Lime and OpenFL. Sometimes, we get features like this for free from the SDL library, but I’m not sure if SDL has something like this or not.