Extending xJSFL

Categories:Extensibility

Overview

xJSFL itself does a pretty good job of turning JSFL in a usable, coherent ecosystem within which to develop elegant, functional, JSFL scripts. However, it also allows you to extend and build upon the base framework with your own libraries and modules.

This section provides a brief run down along with some technical background on the ways to do this, and is followed up in the Tutorials section with some practical examples.

Ways to extend xJSFL

JavaScript objects

You can write your own JavaScript functions, libraries and classes which can be loaded and attached to the framework when Flash first loads via the user bootstrap.

Each function, object or class will first need to registered via xjsfl.classes.register(), then each time the framework is initialized, the objects will be extracted into the initialization scope along with the main framework code.

The following page discusses the process in detail, and in case you are unsure of what kind of functionality you can add, here are some examples of existing xJSFL functionality.

Functions

There are few global functions in xJSFL, as typically functionality will be namespaced to a library, but some examples are:

trace('Hello world!');
$(':selected');
$$('path/to/:movieclip');
Libraries

Libraries are typically standard JavaScript Object objects with functions (methods) that are accessed statically by the developer; examples being:

Output.inspect(dom);
Superdoc.appearance.fill;
Timer.start();
Classes

Classes, and sometimes Datatypes, are typically JavaScript functions that are instantiated with the new keyword to create instances of objects (classes) that can be updated, modified and used in programming code; examples being:

var file = new File('c:/temp/test.txt');
var config = new Config('snippets');
var table = new Table(data);

Modules

Modules are specific to xJSFL, and are in fact mini-user folders, containing subfolders of assets, config, scripts, libraries and UI, or any other folders you like, that work as stand-alone applications within the xJSFL framework.

The framework itself is aware of each registered Module, and file handling is designed to include module folders when searching for and loading files.

The Snippets panel, for example, is a Module, and is made up of:

  • core JSFL functionality extended from the Module class
  • custom JSFL functionality added by the developer
  • data and settings files, using the Config class
  • an SWF panel that serves as a sophisticated interface to the module's JSFL functionality
  • an assets folder providing 1000+ of PNG icons for the SWF panel

Modules of this kind are typically built with the AS3 Module framework which provides a standard methodology and base code for easing communication between AS3 and JSFL without resorting to complicated strings passed around with MMExecute.

You would typically develop a Module when:

  • having separate, related, files in the user folder becomes too cumbersome
  • you want to develop a tool or JSFL application that requires distribution
  • you want to manage discrete sets of files as separate, ongoing projects

Keeping files in the user folder or creating a Module is entirely at the discretion of the developer.

Next steps

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>