Topic: Flash / Widget environment constants

I read through the wiki again and I am certain that there were more than 2 environment variables available to our Flash widgets... right?

All I seem to find is

_chumby_chumby_name
and
_chumby_widget_instance_id


What others are available? In particular does the chumby environment provide the time that the widget is going to show?


I am thinking about creating a fun widget that is "aware" of its own show-time and could pick up where it left off the next time it is seen. Without having to constantly post its state to a remote service, it would be nice to just do it once before it finishes.

Thanks for the info.

John Forsythe
www.jforsythe.com

-John Forsythe
www.jforsythe.com

Re: Flash / Widget environment constants

Ahh okay I found it again while I was looking at the XML profiles available to the movies.

Here is the base xml structure I see:

<profile id="{GUID}">
  <name>channel name</name>
  <description></description>
  <user username="my username"/>
  <widget_instances>
    <widget_instance>
      <widget>
        <name>Widget Name</name>
        <description>Widget description</description>
        <version>1.0</version>
        <mode time="130" mode="timeout"/>
        <movie href="/xml/movies/{guid}" contenttype="application/x-shockwave-flash" />
      </widget>

      <mode time="15" mode="timeout"/>

      <widget_parameters>
        <widget_parameter id="{guid}">
          <name>paramname</name>
          <value>paramvalue</value>
        </widget_parameter>
      </widget_parameters>

    </widget_instance>

    {...}

  </widget_instances>
</profile>

What I am looking for is available in the <mode time="15" mode="timeout"/> node.

-John Forsythe
www.jforsythe.com

Re: Flash / Widget environment constants

I was poking around the controlPanel found some code that may be useful to most flash developers

Here's the chumby's basic init sequence...

    function setupHeartbeat() {
        this.createEmptyMovieClip("heartbeat", 1);
        heartbeat.g_nextHeartbeat = 0;
        heartbeat.onEnterFrame = function () {
            var timeNow = getTimer();
            if (timeNow >= g_nextHeartbeat) {
                trace ("(Master heartbeat)");
                Object._chumby.putFile("/tmp/movieheartbeat", "1");
                g_nextHeartBeat = timeNow + 15000;
            }
        };
    }
    function fetchChumbyGUID() {
        trace ("Fetching Chumby GUID");
        panel.setLabel("Identifying chumby...");
        getChumbyGUIDXML = new XML ();
        getChumbyGUIDXML.target = this;
        getChumbyGUIDXML.onData = function (data) {
            if (data.length) {
                this.target.gotChumbyGUID(data);
            } else {
                trace ("- can\'t load Chumby GUID");
                this.target.fetchNetworkStatus();
             }
        };
        if (_root.test) {
            getChumbyGUIDXML.load("chumbyguid.xml");
        } else {
            getChumbyGUIDXML.load("exec://guidgen.sh");
         }
    }
    function gotChumbyGUID(guid) {
        Object._chumby.g_guid = Object.chomp(guid.toUpperCase());
        trace (("- GUID=\"" + Object._chumby.g_guid) + "\"");
        delete getChumbyGUIDXML;
        fetchMacAddress();
    }
    function fetchMacAddress() {
        panel.setLabel("Checking network devices");
        if (_root.test) {
            Object._chumby.macAddress = "00:00:00:00:00:00";
            fetchNetworkStatus();
        } else {
            trace ("Fetching MAC address");
            getMacAddressXML = new XML ();
            getMacAddressXML.target = this;
            getMacAddressXML.onData = function (data) {
                if (data.length) {
                    this.target.gotMacAddress(data);
                } else {
                    trace ("- can\'t load MAC address");
                    this.target.fetchNetworkStatus();
                 }
            };
            getMacAddressXML.load("exec://macgen.sh");
         }
    }
    function gotMacAddress(address) {
        Object._chumby.macAddress = Object.chomp(address);
        trace ("- MAC: " + Object._chumby.macAddress);
        delete getMacAddressXML;
        fetchNetworkStatus();
    }
    function fetchNetworkStatus() {
        panel.setLabel("Checking network status");
        trace ("Fetching network status");
        if (_root.test) {
            Object._chumby.hasNetwork = hasLocalNetwork;
            dispatch();
        } else {
            Object._chumby.hasNetwork = false;
            networkXML = new XML ();
            networkXML.target = this;
            networkXML.onLoad = function (success) {
                if (success) {
                    this.target.gotNetworkStatus(this.firstChildOfType("network"));
                } else {
                    trace ("- failed to get network status");
                    this.target.dispatch();
                 }
            };
            networkXML.load("exec://network_status.sh");
         }
    }
    function gotNetworkStatus(network) {
        if (network != undefined) {
            var interface = network.firstChildOfType("interface");
            if (interface != undefined) {
                var errors = interface.childrenOfType("error");
                Object._chumby.hasNetwork = !(errors && (errors.length > 0));
                if (Object._chumby.hasNetwork) {
                    Object._chumby.ip = interface.attributes.ip;
                    Object._chumby.netmask = interface.attributes.netmask;
                    Object._chumby.gateway = interface.attributes.gateway;
                    Object._chumby.nameserver1 = interface.attributes.nameserver1;
                    Object._chumby.nameserver2 = interface.attributes.nameserver2;
                    var config = network.firstChildOfType("configuration");
                    Object._chumby.ssid = config.attributes.ssid;
                }
            }
        }
        trace ("- network status: " + Object._chumby.hasNetwork);
        dispatch();
    }
    function dispatch() {
        if (safeMode != undefined) {
            gotoAndStop (8);
        } else if (builtin) {
            gotoAndStop (10);
        } else if (firstTime) {
            gotoAndStop (3);
        } else {
            gotoAndStop (4);
         }
    }
    function restoreSettings() {
        trace ("Restoring settings");
        if (!_root.test) {
            Object._chumby._setOverlayVisibility(255);
            Object._chumby._setOverlayBlendingEnabled(1);
            Object._chumby._switchDisplay(1);
            trace ("- restoring dimlevel");
            var v = Object._chumby.getFile("/psp/dimlevel");
            Object._chumby._setLCDMute(v);
        }
    }
    Date.month_names = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
    Date.month_names_short = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
    Date.day_names = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
    Date.day_names_short = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
    Date.prototype.format = function (f) {
        var result = new String ();
        var i = 0;
        while (i < f.length) {
            var c = f.charAt(i++);
            if (c == "%") {
                c = f.charAt(i++);
                if ((c == "E") || (c == "O")) {
                    c = f.charAt(i++);
                }
                if (c == "a") {
                    result = result + Date.day_names_short[this.getDay()];
                } else if (c == "A") {
                    result = result + Date.day_names[this.getDay()];
                } else if ((c == "b") || (c == "h")) {
                    result = result + Date.month_names_short[this.getMonth()];
                } else if (c == "B") {
                    result = result + Date.month_names[this.getMonth()];
                } else if (c == "C") {
                    var century = int (this.getFullYear() / 100);
                    result = result + (((century < 10) ? "0" : "") + century);
                } else if (c == "d") {
                    var dom = this.getDate();
                    result = result + (((dom < 10) ? "0" : "") + dom);
                } else if (c == "D") {
                    result = result + this.format("%m/%d/%y");
                } else if (c == "e") {
                    var dom = this.getDate();
                    result = result + (((dom < 10) ? " " : "") + dom);
                } else if (c == "F") {
                    result = result + this.format("%Y-%m-%d");
                } else if (c == "G") {
                    result = result + this.getFullYear();
                } else if (c == "g") {
                    result = result + (this.getFullYear() % 100);
                } else if (c == "H") {
                    var hour = this.getHours();
                    result = result + (((hours < 10) ? "0" : "") + hours);
                } else if (c == "I") {
                    hours = this.getHours();
                    if (hours > 12) {
                        hours = hours - 12;
                    }
                    if (hours == 0) {
                        hours = 12;
                    }
                    result = result + (((hours < 10) ? "0" : "") + hours);
                } else if (c == "j") {
                    var d = (this.getTime() - new Date (this.getFullYear(), 0).getTime());
                    d = int (d / 86400000);
                    result = result + ((((d < 100) ? "0" : "") + ((d < 10) ? "0" : "")) + d);
                } else if (c == "k") {
                    var hours = this.getHours();
                    result = result + (((hours < 10) ? " " : "") + hours);
                } else if (c == "l") {
                    var hours = this.getHours();
                    if (hours > 12) {
                        hours = hours - 12;
                    }
                    if (hours == 0) {
                        hours = 12;
                    }
                    result = result + (((hours < 10) ? " " : "") + hours);
                } else if (c == "m") {
                    var month = (this.getMonth() + 1);
                    result = result + (((month < 10) ? "0" : "") + month);
                } else if (c == "M") {
                    var minutes = this.getMinutes();
                    result = result + (((minutes < 10) ? "0" : "") + minutes);
                } else if (c == "n") {
                    result = result + newline;
                } else if (c == "p") {
                    result = result + ((this.getHours() >= 12) ? "PM" : "AM");
                } else if (c == "P") {
                    result = result + ((this.getHours() >= 12) ? "pm" : "am");
                } else if (c == "r") {
                    result = result + this.format("%I:%M:%S %p");
                } else if (c == "R") {
                    result = result + this.format("%H:%M");
                } else if (c == "s") {
                    result = result + int (this.getTime() / 1000);
                } else if (c == "S") {
                    var seconds = this.getSeconds();
                    result = result + (((seconds < 10) ? "0" : "") + seconds);
                } else if (c == "t") {
                    result = result + "\t";
                } else if (c == "T") {
                    result = result + this.format("%H:%M:%S");
                } else if (c == "u") {
                    var dow = this.getDay();
                    if (dow == 0) {
                        dow = 7;
                    }
                    result = result + dow;
                } else if (c == "w") {
                    result = result + this.getDay();
                } else if (c == "x") {
                    result = result + this.format("%m/%d/%y");
                } else if (c == "X") {
                    result = result + this.format("%H:%M:%S");
                } else if (c == "y") {
                    year = this.getYear() % 100;
                    result = result + (((year < 10) ? "0" : "") + year);
                } else if (c == "Y") {
                    result = result + this.getFullYear();
                } else if (c == "z") {
                    result = result + (-int (this.getTimeZoneOffset() / 60));
                } else if (c == "%") {
                    result = result + "%";
                } else {
                    result = result + ("%" + c);
                 }
            } else {
                result = result + c;
             }
        }
        return (result);
    };
    Date.isLeap = function (y) {
        if ((y % 400) == 0) {
            return (true);
        }
        if ((y % 100) == 0) {
            return (false);
        }
        return ((y % 4) == 0);
    };
    Date.daysInMonth = function (m, y) {
        if (m == 1) {
            return (28 + (Date.isLeap(y) ? 1 : 0));
        }
        return ([31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][m]);
    };
    ASSetPropFlags(Date, "month_names,month_names_short,day_names,day_names_short", 7);
    ASSetPropFlags(Date.prototype, "format,isLeap,daysInMonth", 7);
    Object.prototype.xpath_string = function (path) {
        if (this.nodeType != 1) {
            trace ("Error in xpath_string");
            return ("Error");
        }
        var root = this;
        var s = new String (path);
        var tokens = s.split("/");
        while (tokens.length > 0) {
            if (tokens[0].charAt(0) == "@") {
                return (root.attributes[tokens[0].substring(1)]);
            } else {
                var nodes = root.childNodes;
                var found = false;
                var i = 0;
                while (i < nodes.length) {
                    if (nodes[i].nodeName == tokens[0]) {
                        if (tokens.length == 1) {
                            return (nodes[i].firstChild.nodeValue);
                        } else {
                            root = nodes[i];
                            tokens.shift();
                            found = true;
                            break;
                         }
                    }
                    i++;
                }
                if (!found) {
                    return ("");
                }
             }
        }
        return ("");
    };
    Object.prototype.xpath_node = function (path) {
        if (this.nodeType != 1) {
            trace ("Error in xpath_string");
            return ("Error");
        }
        var root = this;
        var s = new String ();
        s = path;
        var tokens = s.split("/");
        while (tokens.length > 0) {
            var nodes = root.childNodes;
            var found = false;
            var i = 0;
            while (i < nodes.length) {
                if (nodes[i].nodeName == tokens[0]) {
                    if (tokens.length == 1) {
                        return (nodes[i]);
                    } else {
                        root = nodes[i];
                        tokens.shift();
                        found = true;
                        break;
                     }
                }
                i++;
            }
            if (!found) {
                return (null);
            }
        }
        return (null);
    };
    Object.prototype.childrenOfType = function (s, a) {
        if (a == undefined) {
            a = new Array ();
        }
        var n = this.firstChild;
        while (n) {
            if (n.nodeName == s) {
                a.push(n);
            }
            n = n.nextSibling;
        }
        return (a);
    };
    Object.prototype.cloneChildrenOfType = function (s, a) {
        if (a == undefined) {
            a = new Array ();
        }
        var n = this.firstChild;
        while (n) {
            if (n.nodeName == s) {
                a.push(n.cloneNode(true));
            }
            n = n.nextSibling;
        }
        return (a);
    };
    Object.prototype.childrenOfTypeAnd = function (s, f, a) {
        if (a == undefined) {
            a = new Array ();
        }
        var n = this.firstChild;
        while (n) {
            if ((n.nodeName == s) && (f(n))) {
                a.push(n);
            }
            n = n.nextSibling;
        }
        return (a);
    };
    Object.prototype.childrenThat = function (f, a) {
        if (a == undefined) {
            a = new Array ();
        }
        var n = this.firstChild;
        while (n) {
            if (f(n)) {
                a.push(n);
            }
            n = n.nextSibling;
        }
        return (a);
    };
    Object.prototype.firstChildOfType = function (s) {
        var n = this.firstChild;
        while (n) {
            if (n.nodeName == s) {
                return (n);
            }
            n = n.nextSibling;
        }
        return (null);
    };
    Object.prototype.firstChildThat = function (f) {
        var n = this.firstChild;
        while (n) {
            if (f(n)) {
                return (n);
            }
            n = n.nextSibling;
        }
        return (null);
    };
    Object.prototype.firstChildOfTypeAnd = function (s, f) {
        var n = this.firstChild;
        while (n) {
            if ((n.nodeName == s) && (f(n))) {
                return (n);
            }
            n = n.nextSibling;
        }
        return (null);
    };
    Object.prototype.nextSiblingOfType = function (s) {
        var n = this.nextSibling;
        while (n) {
            if (n.nodeName == s) {
                return (n);
            }
            n = n.nextSibling;
        }
        return (null);
    };
    Object.prototype.previousSiblingOfType = function (s) {
        var n = this.previousSibling;
        while (n) {
            if (n.nodeName == s) {
                return (n);
            }
            n = n.previousSibling;
        }
        return (null);
    };
    Object.prototype.firstDescendantOfType = function (s) {
        var n = this.firstChildOfType(s);
        if (n) {
            return (n);
        }
        n = this.firstChild;
        while (n) {
            var k = n.firstDescendantOfType(s);
            if (k) {
                return (k);
            }
            n = n.nextSibling;
        }
        return (null);
    };
    Object.prototype.descendantsOfType = function (s, a) {
        if (a == undefined) {
            a = new Array ();
        }
        var n = this.firstChild;
        while (n) {
            if (n.nodeType == 1) {
                if (n.nodeName == s) {
                    a.push(n);
                }
                a = n.descendantsOfType(s, a);
            }
            n = n.nextSibling;
        }
        return (a);
    };
    Object.prototype.firstValueOfType = function (s) {
        var n = this.firstChild;
        while (n) {
            if (n.nodeName == s) {
                return (n.firstChild.nodeValue);
            }
            n = n.nextSibling;
        }
        return (null);
    };
    ASSetPropFlags(Object.prototype, "xpath_string,xpath_node,childrenOfType,cloneChildrenOfType,childrenOfTypeAnd,childrenThat,firstChildOfType,firstChildOfTypeAnd,firstChildThat,nextSiblingOfType,previousSiblingOfType,firstDescendantOfType,descendantsOfType,firstValueOfType", 7);
    Object.prototype.dumpFields = function () {
        trace ((((("Fields of " + this) + " <") + typeof (this)) + "> path ") + targetPath (this));
        for (var index in this) {
            var obj = this[index];
            trace ((((((("   [" + index) + "]: ") + obj) + " <") + typeof (obj)) + "> path ") + targetPath (obj));
        }
    };
    ASSetPropFlags(Object.prototype, "dumpFields", 7);
    Array.prototype.sortshuffle = function () {
        var shuffler = function (a, b) {
            return ((random (2) * 2) - 1);
        };
        this.sort(shuffler);
    };
    Array.prototype.shuffle = function () {
        var len = this.length;
        var it = 0;
        while (it < len) {
            var rn = random (len);
            var el = this[it];
            this[it] = this[rn];
            this[rn] = el;
            it++;
        }
    };
    Array.prototype.copy = function () {
        return (this.slice(0));
    };
    Array.prototype.removeDuplicates = function () {
        var inc0 = 0;
        while (inc0 < (this.length - 1)) {
            var inc1 = (inc0 + 1);
            while (inc1 < this.length) {
                if (this[inc0] == this[inc1]) {
                    this.splice(inc1--, 1);
                }
                inc1++;
            }
            inc0++;
        }
    };
    ASSetPropFlags(Array.prototype, "sortshuffle,shuffle,copy,removeDuplicates", 7);
    TextField.prototype.autoResize = function (minn, maxx) {
        if (this.autosizeFormat == null) {
            this.autosizeFormat = new TextFormat ();
            this.autosizeFormat.size = 6;
        }
        if (minn == null) {
            minn = 1;
        }
        if (maxx == null) {
            maxx = 99;
        }
        if (minn >= maxx) {
            this.autosizeFormat.size = minn;
            this.setTextFormat(this.autosizeFormat);
        } else if (this.text.length > 0) {
            this.autosizeFormat.size = this.autosizeFormat.size - 5;
            this.setTextFormat(this.autosizeFormat);
            if ((this.textHeight > this._height) || (this.textWidth > this._width)) {
                while ((this.textHeight > this._height) || (this.textWidth > this._width)) {
                    this.autosizeFormat.size--;
                    this.setTextFormat(this.autosizeFormat);
                }
            } else {
                while ((this.textHeight < this._height) && (this.textWidth < this._width)) {
                    this.autosizeFormat.size++;
                    this.setTextFormat(this.autosizeFormat);
                }
                this.autosizeFormat.size = this.autosizeFormat.size - 2;
                this.setTextFormat(this.autosizeFormat);
             }
            this.autosizeFormat.size = Math.min(Math.max(minn, this.autosizeFormat.size), maxx);
            this.setTextFormat(this.autosizeFormat);
        }
    };
    ASSetPropFlags(TextField.prototype, "autoResize", 7);
    if (Object._chumby == undefined) {
        Object._chumby = {};
        ASSetPropFlags(Object, "_chumby", 7);
    }
    Object._chumby._getFile = ASnative(5, 50);
    Object._chumby._putFile = ASNative(5, 51);
    Object._chumby._backtick = ASNative(5, 52);
    Object._chumby._fileExists = ASnative(5, 53);
    Object._chumby._getSpeakerMute = ASnative(5, 17);
    Object._chumby._setSpeakerMute = ASnative(5, 18);
    Object._chumby._lightLevel = ASnative(5, 15);
    Object._chumby._getLCDMute = ASnative(5, 19);
    Object._chumby._setLCDMute = ASnative(5, 20);
    Object._chumby._getBrightnessForRange = ASnative(5, 21);
    Object._chumby._setBrightnessForRange = ASnative(5, 22);
    Object._chumby._getBrightnessThresholdForRange = ASnative(5, 23);
    Object._chumby._setBrightnessThresholdForRange = ASnative(5, 24);
    Object._chumby._bendLevel = ASnative(5, 14);
    Object._chumby._bent = ASnative(5, 25);
    Object._chumby._bendAverage = ASnative(5, 28);
    Object._chumby._getBendThreshold = ASnative(5, 26);
    Object._chumby._setBendThreshold = ASnative(5, 27);
    Object._chumby._dcPower = ASnative(5, 16);
    Object._chumby._setOverlayVisibility = ASnative(5, 110);
    Object._chumby._getOverlayVisibility = ASnative(5, 111);
    Object._chumby._setOverlayBlendingEnabled = ASnative(5, 112);
    Object._chumby._getOverlayBlendingEnabled = ASnative(5, 113);
    Object._chumby._setOverlayChromaBlendingEnabled = ASnative(5, 114);
    Object._chumby._getOverlayChromaBlendingEnabled = ASnative(5, 115);
    Object._chumby._setOverlayChromaBlendColor = ASnative(5, 116);
    Object._chumby._getOverlayChromaBlendColor = ASnative(5, 117);
    Object._chumby._setSlaveVar = ASnative(5, 80);
    Object._chumby._getSlaveVar = ASnative(5, 81);
    Object._chumby._routeUIEvents = ASnative(5, 82);
    Object._chumby._switchDisplay = ASnative(5, 83);
    Object._chumby._getCurrentDisplay = ASnative(5, 88);
    Object._chumby._startSlave = ASnative(5, 84);
    Object._chumby._stopSlave = ASnative(5, 85);
    Object._chumby._pauseResumeSlave = ASnative(5, 86);
    Object._chumby._getDefaultSlaveInstance = ASnative(5, 87);
    Object._chumby._expireCache = ASnative(5, 100);
    Object._chumby._expireCacheFiltered = ASnative(5, 101);
    Object._chumby._exitOpportunity = ASnative(5, 120);
    Object.chomp = function (s) {
        while (s.length && ((s.slice(-1) == newline) || (s.slice(-1) == " "))) {
            s = s.slice(0, -1);
        }
        return (s);
    };
    Object._chumby.getFile = function (f) {
        return (Object.chomp(Object._chumby._getFile(f)));
    };
    Object._chumby.putFile = function (f, d) {
        Object._chumby._putFile(f, d + newline);
    };
    Object._chumby.backtick = function (c) {
        return (Object.chomp(Object._chumby._backtick(c)));
    };
    Object._chumby._setTimeZone = ASnative(103, 321);
    Object._chumby._getTimeZone = ASnative(103, 320);
    Date.addProperty("_timezone", ASnative(103, 320), ASnative(103, 321));
    var o = Date.prototype;
    o.setSystemTime = ASnative(103, 322);
    ASSetpropFlags(Object, "chomp", 7);
    ASSetPropFlags(Date.prototype, "setSystemTime", 7);
    ASSetPropFlags(Date, "_timezone", 7);
    Object._chumby.controlPanelVersion = "2.5.44";
    stop();
    trace (((("Welcome to the Chumby Control Panel (version " + Object._chumby.controlpanelVersion) + " [") + _root.$version) + "])");
    if (_root.test == undefined) {
        platform = _root.$version.split(" ")[0];
        _root.test = (platform == "MAC") || (platform == "WIN");
    }
    if (_root.test) {
        local = 1;
        hasLocalNetwork = true;
        defaultProfileTime = 2;
        defaultWidgetTime = 5;
        Object._chumby.hardware_version = "0.9.2";
        Object._chumby.software_version = "0.9.2";
        Object._chumby.firmware_version = "100";
    } else {
        panel.setLabel("Checking hardware version");
        Object._chumby.hardware_version = Object._chumby.backtick("chumby_version -h");
        if (Object._chumby.hardware_version == "") {
            Object._chumby.hardware_version = Object._chumby.getFile("/etc/hardware_version");
            Object._chumby.software_version = Object._chumby.getFile("/etc/software_version");
            Object._chumby.firmware_version = Object._chumby.getFile("/etc/firmware_build");
        } else {
            panel.setLabel("Checking software version");
            Object._chumby.software_version = Object._chumby.backtick("chumby_version -s");
            panel.setLabel("Checking firmware version");
            Object._chumby.firmware_version = Object._chumby.backtick("chumby_version -f");
         }
     }
    if (_root.baseURL == undefined) {
        Object._chumby.baseURL = "http://xml.chumby.com";
        if (_root.test && (_root.local)) {
            Object._chumby.baseURL = "http://0.0.0.0:3000";
            if (platform == "WIN") {
                Object._chumby.baseURL = "http://127.0.0.1:3000";
            }
        }
    } else {
        Object._chumby.baseURL = _root.baseURL;
        trace ("Base URL=" + Object._chumby.baseURL);
     }
    Object._chumby.makeURL = function (u) {
        return (Object._chumby.baseURL + u);
    };
    if (_root.widgetsURL == undefined) {
        Object._chumby.widgetsURL = "http://widgets.chumby.com";
        if (_root.test && (_root.local)) {
            Object._chumby.widgetsURL = "http://0.0.0.0:3000";
            if (platform == "WIN") {
                Object._chumby.baseURL = "http://127.0.0.1:3000";
            }
        }
    } else {
        Object._chumby.widgetsURL = _root.widgetsURL;
        trace ("Widgets URL=" + Object._chumby.widgetsURL);
     }
    Object._chumby.makeWidgetsURL = function (u) {
        return (Object._chumby.widgetsURL + u);
    };
    setupHeartbeat();
    restoreSettings();
    fetchChumbyGUID();

Re: Flash / Widget environment constants

Object._chumby._bendLevel = ASnative(5, 14);
    Object._chumby._bent = ASnative(5, 25);
    Object._chumby._bendAverage = ASnative(5, 28);
    Object._chumby._getBendThreshold = ASnative(5, 26);
    Object._chumby._setBendThreshold = ASnative(5, 27);


I wonder if these properties can be polled and captured while a widget ?

-John Forsythe
www.jforsythe.com

Re: Flash / Widget environment constants

There is a little bit more on using these types of calls hidden on the wiki here:
http://wiki.chumby.com/mediawiki/index. … sor_Access

Here's a static class (warning UNTESTED) that I have started to collect these as I come across them... It may save some typing if someone is thinking a similar approach

class ChumbySensors
{

    private static  var instance:ChumbySensors;

    public static function getInstance():ChumbySensors
    {
        if (instance == null)
        {
            instance=new ChumbySensors();
        }
        return instance;
    }
    private function ChumbySensors()
    {

    }
    
    static function _rawX()
    {
        var func:Function = _global["ASnative"](5, 10);
        return func();// get the last raw touchscreen X coordinate
    }
    
    static function _rawY()
    {
        var func:Function = _global["ASnative"](5, 11);
        return func();// get the last raw touchscreen Y coordinate
    }
    
    static function _setCalibration()
    {
        var func:Function = _global["ASnative"](5, 12);
    }
    
    static function _writeCalibration()
    {
        var func:Function = _global["ASnative"](5, 13);
    }
    
    static function _bendLevel()
    {
        var func:Function = _global["ASnative"](5, 14);
    }
    
    static function _lightLevel()
    {
        var func:Function = _global["ASnative"](5, 15);
    }
    
    static function _dcPower()
    {
        var func:Function = _global["ASnative"](5, 16);
    }
        
    static function _getSpeakerMute()
    {
        var func:Function = _global["ASnative"](5, 17);
        return func();
    }    
    
    static function _setSpeakerMute(b:Boolean)
    {
        var func:Function = _global["ASnative"](5, 18);
        if (b)
        {
            func(1);
        } else
        {
            func(0);
        }
    }

    static function _getLCDMute()
    {
        var func:Function = _global["ASnative"](5, 19);
    }
    
    static function _setLCDMute(n:Number)
    {
        var func:Function = _global["ASnative"](5, 20);
        if (n < 0)
        {
            n=0;
        }
        if (n > 3)
        {
            n=3;
        }
        func(n);
    }
    
    static function _getBrightnessForRange()
    {
        var func:Function = _global["ASnative"](5, 21);
    }
    
    static function _setBrightnessForRange()
    {
        var func:Function = _global["ASnative"](5, 22);
    }
    
    static function _getBrightnessThresholdForRange()
    {
        var func:Function = _global["ASnative"](5, 23);
    }
    
    static function _setBrightnessThresholdForRange()
    {
        var func:Function = _global["ASnative"](5, 24);
    }
    
    static function _bent()
    {
        var func:Function = _global["ASnative"](5, 25);
    }
    
    static function _bendAverage()
    {
        var func:Function = _global["ASnative"](5, 28);
    }
    
    static function _getBendThreshold()
    {
        var func:Function = _global["ASnative"](5, 26);
    }
    
    static function _setBendThreshold()
    {
        var func:Function = _global["ASnative"](5, 27);
    }
    
    static function _getFile(file:String)
    {
        var func:Function = _global["ASnative"](5, 50);
        return func(file);
    }
    
    static function _putFile()
    {
        var func:Function = _global["ASnative"](5, 51);
    }
    
    static function _backtick()
    {
        var func:Function = _global["ASnative"](5, 52);
    }
    
    static function _fileExists(file:String):Boolean
    {
        var func:Function = _global["ASnative"](5, 53);
        return func(file);
    }
    
    static function _setSlaveVar()
    {
        var func:Function = _global["ASnative"](5, 80);
    }
    
    static function _getSlaveVar()
    {
        var func:Function = _global["ASnative"](5, 81);
    }
    
    static function _routeUIEvents()
    {
        var func:Function = _global["ASnative"](5, 82);
    }
    
    static function _switchDisplay()
    {
        var func:Function = _global["ASnative"](5, 83);
    }
    
    static function _getCurrentDisplay()
    {
        var func:Function = _global["ASnative"](5, 88);
    }
    
    static function _startSlave()
    {
        var func:Function = _global["ASnative"](5, 84);
    }
    
    static function _stopSlave()
    {
        var func:Function = _global["ASnative"](5, 85);
    }
    
    static function _pauseResumeSlave()
    {
        var func:Function = _global["ASnative"](5, 86);
    }
    
    static function _getDefaultSlaveInstance()
    {
        var func:Function = _global["ASnative"](5, 87);
    }
    
    static function _expireCache()
    {
        var func:Function = _global["ASnative"](5, 100);
    }
    
    static function _expireCacheFiltered()
    {
        var func:Function = _global["ASnative"](5, 101);
    }
    
    static function _setOverlayVisibility()
    {
        var func:Function = _global["ASnative"](5, 110);
    }
    
    static function _getOverlayVisibility()
    {
        var func:Function = _global["ASnative"](5, 111);
    }
    
    static function _setOverlayBlendingEnabled()
    {
        var func:Function = _global["ASnative"](5, 112);
    }
    
    static function _getOverlayBlendingEnabled()
    {
        var func:Function = _global["ASnative"](5, 113);
    }
    
    static function _setOverlayChromaBlendingEnabled()
    {
        var func:Function = _global["ASnative"](5, 114);
    }
    
    static function _getOverlayChromaBlendingEnabled()
    {
        var func:Function = _global["ASnative"](5, 115);
    }
    
    static function _setOverlayChromaBlendColor()
    {
        var func:Function = _global["ASnative"](5, 116);
    }
    
    static function _getOverlayChromaBlendColor()
    {
        var func:Function = _global["ASnative"](5, 117);
    }
    
    static function _exitOpportunity()
    {
        var func:Function = _global["ASnative"](5, 120);
    }
    
    static function _setTimeZone()
    {
        var func:Function = _global["ASnative"](103, 321);
    }
    
    static function _getTimeZone()
    {
        var func:Function = _global["ASnative"](103, 320);
    }
    /*The force values are read-only, and range 0-4095, with zero point (no force) at 2048,
  and a range of approximately -5 to +5 G. The "current" values are the instantaneous
   value of the sensor, the "avg" values are a running average of the last couple 
   of readings (which will be somewhat smoother), and the "impact" values represent 
   a change in force above a certain threshold. The "impactTime" can be use to detect 
   when the impact occured. The "impactHints" value is used internally by the driver 
   for housekeeping and is currently undocumented.*/
    
    static function _accelerometer(index:Number)
    {
        var get_accelerometer:Function=_global["ASnative"](5,60);
        return get_accelerometer(index);
    }
    
    static function get version()
    {
        return _accelerometer(0);
    }
    
    static function get timestamp()
    {
        return _accelerometer(1);
    }
    
    static function get  currentX()
    {
        return _accelerometer(2);
    }
    
    static function get currentY()
    {
        return _accelerometer(3);
    }
    
    static function get currentZ()
    {
        return _accelerometer(4);
    }
    
    static function get avgX()
    {
        return _accelerometer(5);
    }
    
    static function get avgY()
    {
        return _accelerometer(6);
    }
    
    static function get avgZ()
    {
        return _accelerometer(7);
    }
    
    static function get impactX()
    {
        return _accelerometer(8);
    }
    
    static function get impactY()
    {
        return _accelerometer(9);
    }
    
    static function get impactZ()
    {
        return _accelerometer(10);
    }
    
    static function get impactTime()
    {
        return _accelerometer(11);
    }
    
    static function get impactHints()
    {
        return _accelerometer(12);
    }

}