1 (edited by catdarrow 2011-06-15 12:00:12)

Topic: How do I access the local file system in AS3?


I see a lot of useful functions at http://wiki.chumby.com/index.php/ChumbyNative which I'd love to use, but I am doing development in AS3.  And as near as I can tell, ASNative(a,b) doesn't work in AS3. 

http://wiki.chumby.com/index.php/Develo … sor_Access seems to imply there's a way to do it, but I can't figure out the syntax.  Neither of the examples given there seem to work; ASnative(a,b) doesn't compile, and ["ASnative"] seems to think it's an array containing a string.

If I want to read or write a file in AS3 -- running as a master instance, mind you, and perfectly willing to mess with the system over ssh in any way necessary to prepare it -- how should I go about it?

2 (edited by catdarrow 2011-06-15 15:25:35)

Re: How do I access the local file system in AS3?

In case it helps anyone, I have resorted to a rather perverse technique: CGI scripts.

As a simple proof of concept, I am experimenting with dimming and brightening the screen.  I have a pair of CGI scripts located on the Chumby in /www/cgi-bin/custom.  They look like this:


echo "HTTP/1.1 200 ok"
echo "Content-type:  text/html"
echo "Pragma-directive: no-cache"
echo "Cache-directive: no-cache"
echo "Cache-control: no-cache"
echo "Pragma: no-cache"
echo "Expires: 0"
echo ""
echo 25 > /sys/devices/platform/silvermoon-bl/backlight/silvermoon-bl/brightness

This allows me to set the screen brightness from my web browser --


-- dims the screen.

From there, I can allow a local flash movie to call the same CGI script. 

    var dimloader:URLLoader = new URLLoader();
    var dimrequest:URLRequest = new URLRequest("http://chumby.i.p.address/cgi-bin/custom/dim.cgi");

From there, it's a simple matter of remembering to set the publish settings to 10.1 and the security sandbox to local-with-network, and copying the app into /mnt/storage .

Speaking of security, it would seem rather reckless to use this trick to expose the filesystem in general.  I'm seriously considering writing a bare bones web server that only accepts connections from localhost.

There's *got* to be a less perverse way to do this.

Re: How do I access the local file system in AS3?

We've created our own set of ActionScript Extensions for AS3 to cover much of the functionality that the ASNatives provided for AS2 apps.  There are still some issues to be fixed before we can release it - most likely it will appear on developer.chumby.com in sync with the official release of a new c8 firmware.

afaik, you'll need Adobe Flash CS5 to build apps that leverage these extensions.
More info coming...

Re: How do I access the local file system in AS3?

Well, that's very helpful to know!  I figured something like that would be the case, this work coming so closely on the heels of AS3 availability on the Chumby.

I know it may be inappropriate to ask for a release date, but it does matter to me; I hate to do the workaround with CGI if there's a better way.  Are we talking days?  Weeks?  Months?

Re: How do I access the local file system in AS3?

Hey!  I see the firmware has rolled to a new version.  Does that mean those AS3 hooks are in?  Can I get some documentation on what they are and how they work?

Re: How do I access the local file system in AS3?

Added the ChumbyCore.as Extension Class and some documentation on developer.chumby.com:

Re: How do I access the local file system in AS3?

Great!  Thanks for the swift response!