-
Notifications
You must be signed in to change notification settings - Fork 16
Battery
patrickkulling edited this page Sep 30, 2011
·
4 revisions
If you are interested in Battery status updates of your device you can create a new Battery instances via:
var battery : Battery = new Battery();
After the instance was created you can listen to the BatteryEvent.UPDATE event. Because the device itself will trigger battery status updates, you need to listen to this event.
battery.addEventListener(BatteryEvent.UPDATE, handleBatteryUpdate);
In your handler you've access to all battery information:
private function handleBatteryUpdate(event : BatteryEvent) : void
{
trace("level", event.level);
trace("scale", event.scale);
trace("temperature", event.temperature);
trace("voltage", event.voltage);
}
Call this function if you don't need the class anymore to free your memory.