AS3 JSFL Lib complete

Categories:Blog

The AS3 JSFL Library is complete! This allows for simple, straightforward communication with JSFL from a Flash panel.

Methods are optimised to:

  • Operate by default within the fl.config folder so short paths can be passed in
  • Serialize and deserialize native AS3 / JavaScript objects using the library from Exanimo
  • Log actions in the background, including error and success messages, execution times and durations
  • Output internal debugging information and formatted logs

Logging

The logging and debugging is especially helpful in keeping in touch with what's actually happening beneath the hood. Here's some test log information:

JSFL Message Log
-----------------------------------------------------------------------
00:00:077 > File "xJSFL/core/assets/icons/icons.xml" was read in 58ms
00:00:077 > The XML is 77520 characters...
00:03:146 > File "xJSFL/modules/snippets/lib/test.jsfl" ran in 2ms
00:03:147 > Function "testFunction" executed in 0ms

You can also inspect returned data, which will have been automatically deserialized into their appropriate ActionScript datatypes:

Call result
-----------------------------------------------------------------------
Array =>
    0: "hello"
    1: true
    2: 1
    3: "Dave"
    [4] => Array
        0: "name"
        1: 1
        2: 5
    [5] => Object
        name: "Joe Bloggs"
        age: 99

API

The full API is as follows, with a single class for JSFL operations, and a supporting class for logging.

external.JSFL

isPanel

A Boolean indicating if the currect environment is an SWFPanel, and can therefore run MMExecute() commands

run()

Run a JSFL file (and optionally a function) and return the serialized results

call()

Call a loaded  JSFL function and return the serialized results

exec()

Executes arbitrary JSFL by wrapping the code in a function and, optionally returning the serialized results

read()

Reads a file from the local filesystem and returns the results

write()

Writes data to a file on the local filesystem

create()

A utility method to create valid JSFL code by injecting values into a template

trace()

Traces content to the Output Panel in both an SWFPanel and the Flash IDE

clear()

Clears the output panel in both an SWFPanel and the Flash IDE

utils.Output

log()

Log an action to the internal log at the time it happened

inspect()

Output an object in hierarchical format

trace()

Prints a value to the listener in a formatted fashion

dump()

Print the entire contents of the log to the output panel in a formatted fashion

clear()

Clear the log and reset the timer

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>