Output (library)
Overview
Summary
The Output library provides logging functionality, object introspection, and a variety of printing and formatting methods. You will typically use the library in development, to inspect variables, or perhaps to save data to file for reporting or logging tasks.
Contents
API
props(obj, output)
Converts a typical [object Object] string into an [object Class value="1" property="2"] string
Debug the contents of an object and output to the Output panel:
var obj = {a:null, b:1, c:'Hello'};
trace(Output.props(obj));
[object Object a=null b=1 c="Hello"]
list(arr, properties, label, output)
Lists the properties of an object in a human-readable format
List the items of the current selection:
Output.list($selection);
List: Array (depth:1, objects:0, values:4, time:0.0 seconds) -------------------------------------------------------------------------------- array => Array 0: "circle_01" 1: "star" 2: "square" 3: ""
List several properties of a an array of items:
Output.list($library.items, ['name', 'timeline', 'itemType']);
List: Array (depth:2, objects:10, values:10, time:0.0 seconds) -------------------------------------------------------------------------------- array => Array [0] => Array 0: "star graphic" [1] => Timeline 2: "movie clip" [1] => Array 0: "oval_graphic" [1] => Timeline 2: "movie clip" [2] => Array 0: "star" [1] => Timeline 2: "movie clip" [3] => Array 0: "oval" [1] => Timeline 2: "movie clip" [4] => Array 0: "rectangle" [1] => Timeline 2: "movie clip"
Note that Output.list() has also been aliased as a global function, list():
list($selection);
inspect(obj, $depth, $label, $debug, $filters, $callback)
Output object in hierarchical format
The $ arguments of this method are derived using parameter type-shifting, that is, each argument is a different datatype, so they can be supplied in any order. This leaves you flexible to apply some or many properties as you see fit, without having to enter default values.
Inspect the current library items, with a custom label, and limiting the inspection depth to 3 levels:
Output.inspect($library.items, 'Library items', 3);
Library items: Array (depth:4, objects:39, values:120, time:0.0 seconds) -------------------------------------------------------------------------------- array => Array [0] => SymbolItem [timeline] => Timeline name: "star graphic" [layers] => Array [0] => Layer frameCount: 1 currentFrame: 0 layerCount: 1 currentLayer: 0 [bindings] => Array symbolType: "movie clip" sourceFilePath: "" sourceLibraryName: undefined sourceAutoUpdate: undefined scalingGrid: false [scalingGridRect] => Object left: -2147483.648 top: -2147483.648 right: -2147483.648 bottom: -2147483.648 itemType: "movie clip" name: "star graphic" linkageExportForAS: false linkageExportForRS: false linkageImportForRS: false linkageExportInFirstFrame: undefined // additional properties truncated
Note that Output.inspect() has also been aliased as a global function, inspect():
inspect($selection);
table(arr)
Convenience function to Table.print() to output value in tabular format
List the properties of the Preset panel in table format:
Output.table(app.presetPanel.items);
+-----------+----------+-------+-------------------------+-------+----------------------------------------+ | isDefault | isFolder | level | name | open | path | +-----------+----------+-------+-------------------------+-------+----------------------------------------+ | true | true | 0 | Default Presets | false | Default Presets | | true | false | 1 | bounce-in-3D | true | Default Presets/bounce-in-3D | | true | false | 1 | bounce-out-3D | true | Default Presets/bounce-out-3D | | true | false | 1 | bounce-smoosh | true | Default Presets/bounce-smoosh | | true | false | 1 | fly-in-blur-bottom | true | Default Presets/fly-in-blur-bottom | | true | false | 1 | fly-in-blur-left | true | Default Presets/fly-in-blur-left | | true | false | 1 | fly-in-blur-right | true | Default Presets/fly-in-blur-right | | true | false | 1 | zoom-in-3D | true | Default Presets/zoom-in-3D | | true | false | 1 | zoom-out-2D | true | Default Presets/zoom-out-2D | | true | false | 1 | zoom-out-3D | true | Default Presets/zoom-out-3D | | false | true | 0 | Custom Presets | true | Custom Presets | | false | false | 1 | 10 frame on & off | true | Custom Presets/10 frame on & off | | false | false | 1 | 10 frame scale in | true | Custom Presets/10 frame scale in | | false | false | 1 | 25f in 25f hold 10f out | true | Custom Presets/25f in 25f hold 10f out | | false | false | 1 | Scale up and wobble | true | Custom Presets/Scale up and wobble | +-----------+----------+-------+-------------------------+-------+----------------------------------------+
folder(value, depth, output)
View the hierarchy of a folder
Output the user folder in hierarchical format, limiting to 3 levels deep:
Output.folder('user', 3, true);
/user /assets /readme.txt /config /data /readme.txt /settings /readme.txt /test.xml /user.xml /xjsfl.xml /templates /readme.txt /jsfl /bootstrap.jsfl /learning /test script 01.jsfl /libraries /readme.txt /snippets /Demo /Development /Instances /Library /Stage /temp /dom.txt /readme.txt /ui /readme.txt