2

I'm using JSFL to writing some script, I need parse json string from some config files, so I need the JSFL can parse json string, but JSFL seems can't do this. then I thinks to include some json lib, like json.js, to JSFL file.

Way can I include the json.js file to my JSFL file?

Sorry for my english.

Yan Chen
  • 53
  • 2
  • 7

2 Answers2

2

The absolute bare minimum would be:

// #include Config._jsfl
var scriptPath = FLfile.uriToPlatformPath(fl.scriptURI);
var scriptPathEnd = scriptPath.lastIndexOf("\\");
scriptPath = scriptPath.slice(0, scriptPathEnd + 1);
fl.runScript(FLfile.platformPathToURI(scriptPath + "Config._jsfl"));            /*jsl:import Config._jsfl*/

This is more or less copied from my code, JSL tags included. I make the extensions on any libraries to be ._jsfl so that if it's in Flash's Commands folder, they don't show up in the menu.

I wrote a set of static classes (a Logging system, URI conversions, array utility functions) and wrote a global include function using them to automatically convert a relative path to an absolute URI based upon the running scripts location so that I could just say include("file._jsfl"); to simplify my scripts. HOWEVER all my scripts have to do that first include as shown above to gain the include function. Since my include function relies on a handful of static classes, I've not pasted it here.

Edit: spelling error.

Mark
  • 1,639
  • 1
  • 15
  • 20
1

If the library is local, you can store it in a subfolder of your Flash config path, i.e.

C:\Users\username\AppData\Local\Adobe\Flash CS6\language\Configuration\jslibs

Then, it is quite easy to include it in a single line:

fl.runScript(fl.configURI + "jslibs/file.js");
PokeJoe
  • 57
  • 1
  • 7