Inspection classes and methods
.toString()
All objects classes in xJSFL have meaningful toString() methods, meaning that it you simply trace the object or class to the Output panel, you'll get something more useful that the fairly anonymous [object Object]. For example:
A File instance
[object File name="dialog.xml"]
A Context instance
[object Context dom="Level 05" timeline="Scene 1" layer[0]="Layer 1" keyframe[0]=0]
A Config instance
[object Config path="xJSFL/user/config/settings/keyframer.xml" nodes=9]
An ItemCollection instance
[object ItemCollection length=23]
Output class
Output is the main class you'll use for inspecting objects, and printing text to the Output panel for debugging. It has a variety of methods, all of which are covered in more detail on the API page for Output, but will be summarised here.
Note that all Output methods are called statically, directly on the class, without creating an instance of Output with the new keyword.
.inspect()
Output.inspect() is the Swiss Army knife of inspection functions! It will recursively trawl an object and print the tree of results directly to the listener, and is useful for inspecting the properties of objects, especially when you're not sure what you have.
Output.inspect(dom.selection[0])
Inspect: SymbolInstance (depth:4, objects:13, values:110, time:0.0 seconds) ---------------------------------------------------------------------------------------------------- object => SymbolInstance instanceType: "symbol" symbolType: "movie clip" effectSymbol: false [libraryItem] => SymbolItem [timeline] => Timeline name: "Symbol 1" [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: "Symbol 1" linkageExportForAS: false linkageExportForRS: false linkageImportForRS: false linkageExportInFirstFrame: undefined linkageIdentifier: undefined linkageClassName: undefined linkageBaseClass: undefined linkageURL: undefined colorAlphaPercent: 100 colorRedPercent: 100 colorGreenPercent: 100 colorBluePercent: 100 colorAlphaAmount: 0 colorRedAmount: 0 colorGreenAmount: 0 colorBlueAmount: 0 colorMode: "none" filters: undefined blendMode: "normal" cacheAsBitmap: false firstFrame: undefined loop: undefined actionScript: "" accName: "" description: "" shortcut: "" tabIndex: 0 silent: false forceSimple: false buttonTracking: undefined brightness: [ SKIPPING! ] tintColor: [ SKIPPING! ] tintPercent: [ SKIPPING! ] elementType: "instance" name: "" left: 66.5 top: 33.5 width: 90 height: 90 locked: false [matrix] => Object a: 1 b: 0 c: 0 d: 1 tx: 66.5 ty: 33.5 depth: 0 [layer] => Layer name: "Layer 1" layerType: "normal" visible: true locked: false frameCount: 1 [frames] => Array [0] => Frame name: "" actionScript: "" [elements] => Array startFrame: 0 duration: 1 soundLibraryItem: null soundEffect: "none" soundName: "" soundSync: "stream" soundLoopMode: "repeat" soundLoop: 1 tweenType: "none" tweenEasing: 0 motionTweenScale: true motionTweenRotate: "auto" motionTweenRotateTimes: 0 motionTweenOrientToPath: false motionTweenSync: false motionTweenSnap: false shapeTweenBlend: "distributive" labelType: "none" hasCustomEase: false useSingleEaseCurve: true color: "#4fff4f" height: 100 outline: false parentLayer: null selected: true x: 66.5 y: 33.5 transformX: 111.5 transformY: 78.5 scaleX: 1 scaleY: 1 skewX: 0 skewY: 0 rotation: 0 [transformationPoint] => Object x: 45 y: 45 [objectSpaceBounds] => Object left: -0.499 top: -0.499 right: 90.5 bottom: 90.5
.list()
Output.list() is designed to list specific properties of a selection, object or other elements. It is useful for quickly outputting arrays of objects or selections into something readable by us humans:
Output.list(dom.selection, 'name');
List: Array (depth:1, objects:0, values:15, time:0.0 seconds) ---------------------------------------------------------------------------------------------------- array => Array 0: "bakersfield" 1: "chico" 2: "eureka" 3: "fresno" 4: "la" 5: "medford" 6: "monterey" 7: "palm_springs" 8: "phoenix" 9: "reno" 10: "sacramento" 11: "san_diego" 12: "san_francisco" 13: "santa_barbara" 14: "yuma"
.table()
Output.table() is actually a reference to Table.print(), but is included in the Output class for convenience. As you would expect, it prints a table of objects and properties to the Output panel.
Output.table(xjsfl.get.items());
+-------------------+------------+-----------------+--------------------+------------------+-------------+-----------------+------------+---------------------------------+--------------------+--------------------+--------------------+---------------------------+-------------------+------------------+------------------+------------+ | timeline | symbolType | sourceFilePath | sourceLibraryName | sourceAutoUpdate | scalingGrid | scalingGridRect | itemType | name | linkageExportForAS | linkageExportForRS | linkageImportForRS | linkageExportInFirstFrame | linkageIdentifier | linkageClassName | linkageBaseClass | linkageURL | +-------------------+------------+-----------------+--------------------+------------------+-------------+-----------------+------------+---------------------------------+--------------------+--------------------+--------------------+---------------------------+-------------------+------------------+------------------+------------+ | [object Timeline] | movie clip | .\usa - all.fla | states/alabama | false | false | [object Object] | movie clip | graphics/key folder/alabama | false | false | false | | | | | | | [object Timeline] | movie clip | .\usa - all.fla | states/alaska | false | false | [object Object] | movie clip | graphics/key folder/alaska | false | false | false | | | | | | | [object Timeline] | movie clip | .\usa - all.fla | states/arizona | false | false | [object Object] | movie clip | graphics/key folder/arizona | false | false | false | | | | | | | [object Timeline] | movie clip | .\usa - all.fla | states/arkansas | false | false | [object Object] | movie clip | graphics/key folder/arkansas | false | false | false | | | | | | | [object Timeline] | movie clip | .\usa - all.fla | states/california | false | false | [object Object] | movie clip | graphics/key folder/california | false | false | false | | | | | | | [object Timeline] | movie clip | .\usa - all.fla | states/colorado | false | false | [object Object] | movie clip | graphics/key folder/colorado | false | false | false | | | | | | | [object Timeline] | movie clip | .\usa - all.fla | states/connecticut | false | false | [object Object] | movie clip | graphics/key folder/connecticut | false | false | false | | | | | | +-------------------+------------+-----------------+--------------------+------------------+-------------+-----------------+------------+---------------------------------+--------------------+--------------------+--------------------+---------------------------+-------------------+------------------+------------------+------------+
.folder()
Output.folder() is a wrapper for Data.recurseFolder() with some added functionality to output the visual structure of a folder and subfolders.
Output.folder('user/jsfl/snippets');
/snippets /Demo /Make test Sprites.jsfl /Development /Check variable is defined.jsfl /Copy ActionScript font name.jsfl /Declare stage instances.jsfl /Export SWC.jsfl /Hello World.jsfl /Inspect variables.jsfl /Instances /Instance name from item name.jsfl /Movieclips to Graphics.jsfl /Library /Change selected items type.jsfl /Delete empty folders.jsfl /Inspect selected items.jsfl /Spreadsheet Edit.jsfl
Next steps
Click here to view Handling errors