Managing code
Loading external libraries
If you want to load external files with xJFSL, it's as simple as providing a path or URI to the file:
load('c:/path/to/library.jsfl'); // absolute
load('library.jsfl'); // relative
If you want to load a library over the network, simply specify a UNC URI, like so:
load('file:////<servername>/<drivename>/path/to/library.jsfl');
The best place to load external libraries if you want to use them each time is in your user bootstrap, which can be found at:
xJSFL/user/jsfl/bootstrap.jsfl
You can do this just by including the load() line above, and specifying the file you want to load.
Loading external modules
Overview
xJSFL's folder structure is designed so you can keep all JSFL-related files in one place, but you can also load code from other folders, or even over the network. This is useful in larger teams where you need a central repository of code, or where you have projects saved in different locations.
Code
There are 2 main core methods that take care of loading or finding modules:
- xjsfl.modules.init() - initializes a specific module
- xjsfl.modules.find() - finds all modules on a path, then initializes them
Each of them accepts as its first argument an absolute URI.
Once you know the URI to your module, simply add some code in your user bootstrap and have the module load each time xJSFL loads:
xjsfl.output.trace('Loading Animation Tools...', true);
xjsfl.modules.init('file:///X|/repo/xJSFL/modules/Animation%20Tools/');
Upon restarting Flash you should see something like the following in the output panel:
> xjsfl: LOADING ANIMATION TOOLS MODULE... > xjsfl: REGISTERING MODULE "ANIMATION TOOLS" > xjsfl: added 14 search paths for "X:/repo/xJSFL/modules/Animation Tools/" > xjsfl: assets are already up to date > xjsfl: ready!
If you want to load files over a network, then simply use the network path with UNC notation (note the 4 slashes):
xjsfl.modules.init('file:////SERVER/Files/repo/xJSFL/modules/Animation%20Tools/');
Then, when flash starts, it simply looks in this network location to load the module! Flash doesn't really care – it's still just a URI at the end of the day.
If you have a repo with multiple xJSFL modules in, you can use the find method, and just point to the top-most folder. Note the trailing true, which instructs the modules to initialize (have its bootstrap file run) as well:
xjsfl.output.trace('Finding modules to load...', true);
xjsfl.modules.find('file:///X|/repo/xJSFL/modules/', true);
Comments are closed.