Question
Global Access to Listener Function
Hello All --
I am using a third-party Flash add-on tool that will let me get a device's battery level (among other things) via listeners. The following code is in my first actionscript frame:
-------------------------------------------------------------
import ssp.device.*;
var statusListener:Object = new Object();
// set-up status listener to get battery level
statusListener.getBatteryLevel = function(e)
{
_global.batteryLevel = e;
}
Status.addEventListener(statusListener);
Status.getBatteryLevel();
-------------------------------------------------------------
The final line in the preceding script successfully sets _global.batteryLevel. The problem is that the script is run only once, when the application starts. What I need to be able to do is to call Status.getBatteryLevel() from a battery monitoring movieclip within my main movie. The movieclip runs constantly to update a display of remaining battery charge.
Unfortunately, whenever I try to execute Status.getBatteryLevel() from any frame other than the one where the listener is set-up, the function does not work. Is there something that I need to do to make the function call available globally?
Regards,
-- Phil
I am using a third-party Flash add-on tool that will let me get a device's battery level (among other things) via listeners. The following code is in my first actionscript frame:
-------------------------------------------------------------
import ssp.device.*;
var statusListener:Object = new Object();
// set-up status listener to get battery level
statusListener.getBatteryLevel = function(e)
{
_global.batteryLevel = e;
}
Status.addEventListener(statusListener);
Status.getBatteryLevel();
-------------------------------------------------------------
The final line in the preceding script successfully sets _global.batteryLevel. The problem is that the script is run only once, when the application starts. What I need to be able to do is to call Status.getBatteryLevel() from a battery monitoring movieclip within my main movie. The movieclip runs constantly to update a display of remaining battery charge.
Unfortunately, whenever I try to execute Status.getBatteryLevel() from any frame other than the one where the listener is set-up, the function does not work. Is there something that I need to do to make the function call available globally?
Regards,
-- Phil