Reverse engineering parser for generated AS3 script methods
MethodParser | Reverse engineering parser for generated AS3 script methods |
Private constants | |
multiLineCommentBegin | Regex token for begin of a comment block. |
multiLineCommentEnd | Regex token for end of a comment block. |
singleLineComment | Regex token for a comment to end of line. |
actionKeywords | Regex tokens for recognized graphics actions. |
propertyKeywords | Regex tokens for recognized graphics properties. |
Parsed general properties | |
assetName | Name of the graphical asset. |
classType | Asset class type. |
xMin | Minumum X in the asset’s local reference coordinate system |
yMin | Minumum Y in the asset’s local reference coordinate system |
xMax | Maximum X in the asset’s local reference coordinate system |
yMax | Maximum Y in the asset’s local reference coordinate system |
Parsed stroke properties | |
alpha | Asset alpha transparency level |
rotation | Rotation of asset relative to its parent |
scaleX | Horizontal scaling of the asset |
scaleY | Vertical scaling of the asset |
x | Horizontal offset of the asset relative to its parent |
y | Vertical offset of the asset relative to its parent |
Parsed stroke actions | |
actions | Array of graphical actions defining the asset. |
Public methods | |
parse | Parse a method script. |
dispose | Dispose of references and reset variables. |
Private methods | |
parseAssetName | Scans for an asset name, updates assetName if found. |
parseClassType | Scans for a class type, updates classType if found. |
parseDimensions | Scans for local reference coordinate system dimensions, updates xMin, yMin, xMax, yMax if found. |
parseProperties | Scans for display properties, updates dynamically properties on the parser as they are found. |
parseActions | Scans for actionKeywords method calls. |
parseParameters | Scans action method call parameters, pushes found parameters on the given paramArray reference. |
parseArray | Scans an embedded array parameter from a method call for its values. |
Public static helper | |
stripComments | Strip comments from a script. |
String conversion | |
toString | Transforms parsed properties into a form suitable for debugging. |
private const actionKeywords: String
Regex tokens for recognized graphics actions.
Lines | moveTo, lineTo, curveTo, lineStyle |
Fills | beginFill, endFill, createGradientBox, beginGradientFill |
Objects | drawCircle, drawEllipse, drawRect, drawRoundRect |
Filters | BevelFilter, BlurFilter, DropShadowFilter |
Tweens | Tween, TweenEx, AdvancedTween, PathTween |
public var actions: Array
Array of graphical actions defining the asset.
Each action item is an Object with an actionName property as defined in actionKeywords and a params property giving the parameters for the action. A parameter can be an embedded array of parameters.
private function parseAssetName( script: String ):void
Scans for an asset name, updates assetName if found.
First looks for an assignment to a name property, if not found then looks to extract the name from the method name if it is a createAsset method.
scriptText | text of a script for a graphical asset method |
private function parseClassType( script: String ):void
Scans for a class type, updates classType if found.
Looks to extract the return type from the method if it is a createAsset method.
scriptText | text of a script for a graphical asset method |
private function parseDimensions( script: String ):void
Scans for local reference coordinate system dimensions, updates xMin, yMin, xMax, yMax if found.
Looks for a pattern beginning with ‘Coordinate system’. This information is contained in a comment so parsing should be performed before comments are stripped.
The coordinate system is not essential to recover the definition of an asset, it is used to present the asset in the same way it was defined.
scriptText | text of a script for a graphical asset method |
private function parseProperties( script: String ):void
Scans for display properties, updates dynamically properties on the parser as they are found. See: Parsed stroke properties.
Looks for assignments to defined propertyKeywords.
scriptText | text of a script for a graphical asset method |
private function parseActions( script: String ):void
Scans for actionKeywords method calls. Found actions are pushed into the actions array as objects with an actionName string and a params array.
scriptText | text of a script for a graphical asset method |
private function parseParameters( paramList: String, paramArray: Array ):void
Scans action method call parameters, pushes found parameters on the given paramArray reference. Looks to distinguish simple parameters and embedded arrays.
paramList | script text as found between parentheses on a method call |
paramArray | array where parameters can be placed as strings or arrays |
Regex token for begin of a comment block.
private static const multiLineCommentBegin: String
Regex token for end of a comment block.
private static const multiLineCommentEnd: String
Regex token for a comment to end of line.
private static const singleLineComment: String
Regex tokens for recognized graphics actions.
private const actionKeywords: String
Regex tokens for recognized graphics properties.
private const propertyKeywords: String
Name of the graphical asset.
public var assetName: String
Asset class type.
public var classType: String
Minumum X in the asset’s local reference coordinate system
public var xMin: Number
Minumum Y in the asset’s local reference coordinate system
public var yMin: Number
Maximum X in the asset’s local reference coordinate system
public var xMax: Number
Maximum Y in the asset’s local reference coordinate system
public var yMax: Number
Asset alpha transparency level
public var alpha: Number
Rotation of asset relative to its parent
public var rotation: Number
Horizontal scaling of the asset
public var scaleX: Number
Vertical scaling of the asset
public var scaleY: Number
Horizontal offset of the asset relative to its parent
public var x: Number
Vertical offset of the asset relative to its parent
public var y: Number
Array of graphical actions defining the asset.
public var actions: Array
Parse a method script.
public function parse( scriptText: String ):void
Dispose of references and reset variables.
public function dispose():void
Scans for an asset name, updates assetName if found.
private function parseAssetName( script: String ):void
Scans for a class type, updates classType if found.
private function parseClassType( script: String ):void
Scans for local reference coordinate system dimensions, updates xMin, yMin, xMax, yMax if found.
private function parseDimensions( script: String ):void
Scans for display properties, updates dynamically properties on the parser as they are found.
private function parseProperties( script: String ):void
Scans for actionKeywords method calls.
private function parseActions( script: String ):void
Scans action method call parameters, pushes found parameters on the given paramArray reference.
private function parseParameters( paramList: String, paramArray: Array ):void
Scans an embedded array parameter from a method call for its values.
private function parseArray( paramList: String ):Array
Strip comments from a script.
public static function stripComments( script: String ):String
Transforms parsed properties into a form suitable for debugging.
public function toString():String