ClassParser

Reverse engineering parser for generated AS3 class code.

Summary
ClassParserReverse engineering parser for generated AS3 class code.
Parsed class properties
assetNameName of the graphical asset class.
backgroundColorScene background color.
frameRateAnimation frame rate.
loopStateAnimation loop state.
xMinMinumum X in the scene coordinate system
yMinMinumum Y in the scene coordinate system
xMaxMaximum X in the scene coordinate system
yMaxMaximum Y in the scene coordinate system
sceneGraphArray of parent/child relationships
maskNamesArray of mask name strings
strokeListArray of MethodParsers with stroke shapes and paths
animationA MethodParser with timeline tweens
Public methods
parseParse a class script.
disposeDispose of references and reset variables.
Scene parsing methods
splitScriptSplits a class script into parts.
parseMethodsParses an array of class methods to separate the methods into types.
parseSceneMethodParses a method that defines the parent/child relationships on the scene graph.
parseMaskObjectsParses a method that defines stroke assets as masks.
parseAnimateMethodParses a timeline animation method for defined tweens.
parseStrokeMethodsParses all script methods as stroke methods except those found to define scene relations and animation.
String conversion
toStringTransforms basic parsed properties into a form suitable for debugging.
Property parsing methods
parseAssetNameScans the script for an class asset name, updates assetName.
parseDimensionsScans for scene coordinate system dimensions, updates xMin, yMin, xMax, yMax if found.
parseFrameRateScans for movie animation framerate, updates frameRate if found.

Parsed class properties

assetName

public var assetName: String

Name of the graphical asset class.

backgroundColor

public var backgroundColor: String

Scene background color.

frameRate

public var frameRate: Number

Animation frame rate.

loopState

public var loopState: Boolean

Animation loop state.

xMin

public var xMin: Number

Minumum X in the scene coordinate system

yMin

public var yMin: Number

Minumum Y in the scene coordinate system

xMax

public var xMax: Number

Maximum X in the scene coordinate system

yMax

public var yMax: Number

Maximum Y in the scene coordinate system

sceneGraph

public var sceneGraph: Array

Array of parent/child relationships

maskNames

public var maskNames: Array

Array of mask name strings

strokeList

public var strokeList: Array

Array of MethodParsers with stroke shapes and paths

animation

public var animation: MethodParser

A MethodParser with timeline tweens

Public methods

parse

public function parse(scriptText: String):void

Parse a class script.  Recognized properties in the script are placed in the class properties.  Properties which were not defined in the script will have their default null/NaN values.

Parameters

scriptTexttext of a script for a graphical asset class

dispose

public function dispose():void

Dispose of references and reset variables.

Scene parsing methods

splitScript

private function splitScript(script: String):Array

Splits a class script into parts.  The script is split at every occurence of a private function.

Parameters

scripttext of a script for a graphical asset class

parseMethods

private function parseMethods(scriptArray: Array):void

Parses an array of class methods to separate the methods into types.  Updates sceneGraph, maskNames, animation and strokeList.

Looks for a method that defines the parent/child relationships on the scene graph and mask definitions and parses those if found.  Looks for any timeline animation definition method and parses it if found.  The remaining methods are parsed as methods defining stroke shapes and paths.

Parameters

scriptArrayan array of class method scripts

parseSceneMethod

private function parseSceneMethod(script: String):Array

Parses a method that defines the parent/child relationships on the scene graph.

The parsing is performed by identifying addChild method calls.  Each relationship is placed in an object with a parentName and childName attribute.

Parameters

scripta method script defining scene relations and masks

Returns

Array of relationship objects

parseMaskObjects

private function parseMaskObjects(script: String):Array

Parses a method that defines stroke assets as masks.

The parsing is performed by identifying addChild method calls that are assigned as masks.

Parameters

scripta method script defining scene relations and masks

Returns

Array of mask names

parseAnimateMethod

private function parseAnimateMethod(script: String):MethodParser

Parses a timeline animation method for defined tweens.

Parameters

scriptanimation method script

Returns

A MethodParser object

parseStrokeMethods

private function parseStrokeMethods(scriptArray: Array,
sceneMethodIndex: int,
animateMethodIndex: int):Array

Parses all script methods as stroke methods except those found to define scene relations and animation.

Each method is parsed by a MethodParser in sequence.

Parameters

scriptArrayan array of class method scripts
sceneMethodIndexindex of the scene relation method, -1 if no such method exists
animateMethodIndexindex of the timeline animation method, -1 if no such method exists

Returns

Array of MethodParser objects.

String conversion

toString

public function toString():String

Transforms basic parsed properties into a form suitable for debugging.

Property parsing methods

parseAssetName

private function parseAssetName(script: String):void

Scans the script for an class asset name, updates assetName.

The class name is extracted from ...  ‘class’ AssetName ‘extends’ ...

Parameters

scripttext of a script for a graphical asset class

parseDimensions

private function parseDimensions(script: String):void

Scans for scene coordinate system dimensions, updates xMin, yMin, xMax, yMax if found.

Looks for an SWF attribute with width and height defined.  The coordinate system is not essential to recover the definition of a class.

Parameters

scripttext of a script for a graphical asset class

parseFrameRate

private function parseFrameRate(script: String):void

Scans for movie animation framerate, updates frameRate if found.

Looks for an SWF attribute with frameRate defined.

Parameters

scripttext of a script for a graphical asset class
public var assetName: String
Name of the graphical asset class.
public var backgroundColor: String
Scene background color.
public var frameRate: Number
Animation frame rate.
public var loopState: Boolean
Animation loop state.
public var xMin: Number
Minumum X in the scene coordinate system
public var yMin: Number
Minumum Y in the scene coordinate system
public var xMax: Number
Maximum X in the scene coordinate system
public var yMax: Number
Maximum Y in the scene coordinate system
public var sceneGraph: Array
Array of parent/child relationships
public var maskNames: Array
Array of mask name strings
public var strokeList: Array
Array of MethodParsers with stroke shapes and paths
Reverse engineering parser for generated AS3 script methods
public var animation: MethodParser
A MethodParser with timeline tweens
public function parse(scriptText: String):void
Parse a class script.
public function dispose():void
Dispose of references and reset variables.
private function splitScript(script: String):Array
Splits a class script into parts.
private function parseMethods(scriptArray: Array):void
Parses an array of class methods to separate the methods into types.
private function parseSceneMethod(script: String):Array
Parses a method that defines the parent/child relationships on the scene graph.
private function parseMaskObjects(script: String):Array
Parses a method that defines stroke assets as masks.
private function parseAnimateMethod(script: String):MethodParser
Parses a timeline animation method for defined tweens.
private function parseStrokeMethods(scriptArray: Array,
sceneMethodIndex: int,
animateMethodIndex: int):Array
Parses all script methods as stroke methods except those found to define scene relations and animation.
public function toString():String
Transforms basic parsed properties into a form suitable for debugging.
private function parseAssetName(script: String):void
Scans the script for an class asset name, updates assetName.
private function parseDimensions(script: String):void
Scans for scene coordinate system dimensions, updates xMin, yMin, xMax, yMax if found.
private function parseFrameRate(script: String):void
Scans for movie animation framerate, updates frameRate if found.
Close