Undocumented FLfile

[This is Windows only, since I don't have access to a Mac] FLfile is the file API extension introduced to JSAPI with Flash MX 2004 7.2. You can read more about JSFL File API here, a great article to get you started with File API by Guy Watson.

JSAPI is authoring time only, still Mario Klingemann posted about some possible dangers at his blog. Extensibility of Macromedia products has not been exploited yet, nevertheless the conclusion is that you should know and trust the source of any FLA or MXP…

It’s not always bad intentions that cause damage, a bug in a JSFL file which uses the FLfile.remove command to delete files might prove a disaster. I remember about the guy who deleted all the files in his C: drive by just using FrontPage (back in 98 maybe). As far as I remember, he defined his site at root of his C: drive and when he wanted to remove his site, FrontPage deleted all the files there!

And most of the time, in any API, there are some undocumented functions you don’t know of. In a cross platform API, the reason may be that those functions do not work the same in, or apply at all to, all platforms.

Does FLfile have any? Sure, 3 of them. [On Windows] FLfile.getPlatform() will return platform ID string like “win32″. FLfile.getSystemTempFolder() will return the path to the system temporary folder (not in URI format). FLfile.runCommandLine(param) seems the most useful of all but also the dangerous one. It runs the string parameter you supply on the command line. Does not expect URIs, normal paths are used again, and displays an ugly console window, but you can even run documents with it, actually you can run anything you can normally run using the commandline, as the functions name suggests.

It’s not really a big issue, but if you are paranoid, you can rename the FLfile.dll and use the API with the new name yourself only, this will block any third party extension trying to use FLfile. And if you give it a short name, you can save from some typing too.

It may be possible to write a ‘proxy’ dll named FLfile, that passes the requests to the real FLfile, but does not allow any undocumented function calls and display a confirmation dialog every time remove function is called. This may also come handy when debugging extensions, if it has some debug trace functionality. If I find some free time, I might try doing that.

This entry was posted in Flash.

6 Responses to Undocumented FLfile

  1. Keith Peters says:

    This is a great feature, used with caution of course. It’s kind of funny that as Flash developers we get so freaked out at a command that can, OH MY GOD!, delete files! Just about every other language out there takes it for granted.
    A minor point is that calling it “undocumented” makes it sound kind of unofficial and unsupported. It is very much an official part of the Ellipsis release, and full documentation will be forthcoming.

  2. Thanks for the info Keith.
    Certainly, a delete function in authoring is not something to be really afraid of but just something new.
    And the functions are certainly undocumented, as of yet :)
    Best regards,
    Burak

  3. maliboo says:

    Is it a big problem to rewrite it to add “move to Recycle Bin” instead “hard delete”? For eg. : FLfile.remove(file,bHardDelete) – with second parameter omitted, command will move deleted file/folder to Windows Recycle Bin?… Probably such solution will be Win-only?

  4. John laPlante says:

    Unfortunately, this file api doesn’t have a readline function for parsing individual lines of text. I managed the same thing by writing each line to a array and looping over it.
    var fileUrl = fl.browseForFileURL(“open”,”Select a CSV File for the Table”);
    if(fileUrl != null) {
    var file=FLfile.read(fileUrl);
    var lines = file.split(/\n/);
    lines[0] = trimString(lines[0]);
    for (idx=1;idx

  5. jdcort says:

    i’m just trying to figure out what is “fl” stands for,i mean it’s probably an object,but when i used it with browseForFileURL like, fl.browseForFileURL it gives “undefined”.anybody has any idea of what should i use..?

  6. Hi,
    ‘fl’ is the top level Flash object. It must be a trivial oversight somewhere, if you get ‘undefined’.
    Best regards,
    Burak