[
  {
    "path": ".gitattributes",
    "content": "# Set the default behavior, in case people don't have core.autocrlf set.\n* text=auto\n\n# Explicitly declare text files you want to always be normalized and converted\n# to native line endings on checkout.\n*.js text\n*.as text\n*.html text\n*.less text\n*.json text\n*.text text\n*.bat text\n*.sh text\n\n# Declare files that will always have CRLF line endings on checkout.\n#*.sln text eol=crlf\n\n# Denote all files that are truly binary and should not be modified.\n#*.png binary\n#*.jpg binary"
  },
  {
    "path": ".gitignore",
    "content": "node_modules/\nruntime-compiled.js\n"
  },
  {
    "path": "AS3JS.as3proj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<project version=\"2\">\n  <!-- Output SWF options -->\n  <output>\n    <movie outputType=\"CustomBuild\" />\n    <movie input=\"\" />\n    <movie path=\"bin\\NewProject.swf\" />\n    <movie fps=\"30\" />\n    <movie width=\"800\" />\n    <movie height=\"600\" />\n    <movie version=\"16\" />\n    <movie minorVersion=\"0\" />\n    <movie platform=\"Flash Player\" />\n    <movie background=\"#FFFFFF\" />\n  </output>\n  <!-- Other classes to be compiled into your SWF -->\n  <classpaths>\n    <class path=\"src\" />\n  </classpaths>\n  <!-- Build options -->\n  <build>\n    <option accessible=\"False\" />\n    <option advancedTelemetry=\"False\" />\n    <option allowSourcePathOverlap=\"False\" />\n    <option benchmark=\"False\" />\n    <option es=\"False\" />\n    <option inline=\"False\" />\n    <option locale=\"\" />\n    <option loadConfig=\"\" />\n    <option optimize=\"True\" />\n    <option omitTraces=\"True\" />\n    <option showActionScriptWarnings=\"True\" />\n    <option showBindingWarnings=\"True\" />\n    <option showInvalidCSS=\"True\" />\n    <option showDeprecationWarnings=\"True\" />\n    <option showUnusedTypeSelectorWarnings=\"True\" />\n    <option strict=\"True\" />\n    <option useNetwork=\"True\" />\n    <option useResourceBundleMetadata=\"True\" />\n    <option warnings=\"True\" />\n    <option verboseStackTraces=\"False\" />\n    <option linkReport=\"\" />\n    <option loadExterns=\"\" />\n    <option staticLinkRSL=\"True\" />\n    <option additional=\"\" />\n    <option compilerConstants=\"\" />\n    <option minorVersion=\"\" />\n  </build>\n  <!-- SWC Include Libraries -->\n  <includeLibraries>\n    <!-- example: <element path=\"...\" /> -->\n  </includeLibraries>\n  <!-- SWC Libraries -->\n  <libraryPaths>\n    <!-- example: <element path=\"...\" /> -->\n  </libraryPaths>\n  <!-- External Libraries -->\n  <externalLibraryPaths>\n    <!-- example: <element path=\"...\" /> -->\n  </externalLibraryPaths>\n  <!-- Runtime Shared Libraries -->\n  <rslPaths>\n    <!-- example: <element path=\"...\" /> -->\n  </rslPaths>\n  <!-- Intrinsic Libraries -->\n  <intrinsics>\n    <!-- example: <element path=\"...\" /> -->\n  </intrinsics>\n  <!-- Assets to embed into the output SWF -->\n  <library>\n    <!-- example: <asset path=\"...\" id=\"...\" update=\"...\" glyphs=\"...\" mode=\"...\" place=\"...\" sharepoint=\"...\" /> -->\n  </library>\n  <!-- Class files to compile (other referenced classes will automatically be included) -->\n  <compileTargets>\n    <compile path=\"src\\com\\mcleodgaming\\as3js\\Main.as\" />\n  </compileTargets>\n  <!-- Paths to exclude from the Project Explorer tree -->\n  <hiddenPaths>\n    <hidden path=\"obj\" />\n  </hiddenPaths>\n  <!-- Executed before build -->\n  <preBuildCommand>node build.js</preBuildCommand>\n  <!-- Executed after build -->\n  <postBuildCommand alwaysRun=\"False\" />\n  <!-- Other project options -->\n  <options>\n    <option showHiddenPaths=\"False\" />\n    <option testMovie=\"Unknown\" />\n    <option testMovieCommand=\"\" />\n  </options>\n  <!-- Plugin storage -->\n  <storage>\n    <entry key=\"at_enabled\"><![CDATA[0]]></entry>\n    <entry key=\"at_password\"><![CDATA[]]></entry>\n  </storage>\n</project>"
  },
  {
    "path": "AS3JS.lxml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<SWCProject xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n  <FlexBinPath />\n  <FlashBinPath />\n  <FlexIncludeASI>false</FlexIncludeASI>\n  <MakeCS3>false</MakeCS3>\n  <MakeMXI>false</MakeMXI>\n  <IntegrateAsDoc>true</IntegrateAsDoc>\n  <LaunchAEM>false</LaunchAEM>\n  <MXPIncludeASI>false</MXPIncludeASI>\n  <Flex_IgnoreClasses />\n  <CS3_IgnoreClasses />\n  <CS3_PreviewType>None</CS3_PreviewType>\n</SWCProject>"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2015 Greg McLeod <cleod9{at}gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"
  },
  {
    "path": "Readme.md",
    "content": "# AS3JS (deprecated) #\n\n----------\n\n### NOTICE: Due to lack of interest this project is no longer maintained. ###\n\nI appreciate everyone who starred the project and participated in the discussions. Maybe some day we'll see true strictly typed JavaScript in some other form :)\n\n----------\n\n**NEW:** **Try AS3JS [live in your browser!](https://jsfiddle.net/cleod9/r1kn2cxf/12/embedded/result)** \n\nAS3JS is a tool written for Node.js that converts ActionScript 3.0 to vanilla JavaScript (originally based on [ImportJS](https://github.com/Cleod9/importjs)). This allows you to write your code using the standard AS3 package structure, and have it automatically converted into a standalone JavaScript file. There are many IDE's out there that can easily parse ActionScript files, so why would you pass up this chance at smart JS code-completion in a program such as [FlashDevelop](http://www.flashdevelop.org/wikidocs/index.php?title=Features:Completion) or [FDT](http://fdt.powerflasher.com/)? **AS3JS even compiles its own source code from AS3 to JS!** :)\n\nSo this tool was created with the following goals in mind: \n\n- Write your code in ActionScript\n- Output to **coherent, debugabble** JavaScript!\n\nThe best part about AS3JS is that even if you aren't familiar with AS3 you can still use this tool with a very small learning curve. The only real difference between AS3JS and normal JS code is what I'd like to call **\"outer syntax\"**. The majority of your code stays the same, you just need to change what \"surrounds\" your code. This should hopefully encourage building a much more organized code base in a large application.\n\n\n## Features ##\n\n- Converts ActionScript 3.0 code into readable JavaScript output (Structure based on [ImportJS](https://github.com/Cleod9/importjs))\n- Recursively parses directories for ActionScript files and automatically resolves import dependencies\n- Concatenation into a single .js file\n- Support for Vector type syntax (transpiles to a standard Array)\n- Support for the '*' wildcard symbol for imports\n- Support for AS3's default argument values and the \"...rest\" argument\n- Support for the \"super\" keyword up to the parent level\n- Moderate support for getter/setter methods\n- Mix and match with traditional JS code via the global namespace at your leisure\n- Ultra fast compilation!\n\n### Experimental features ###\n- Allows `require \"module_name\"` at the package level (do not include semicolon, variable `module_name` will be assigned)\n\n## Setup Instructions ##\n\n**Installation Requirements:**\n\n- [Node.js](http://nodejs.org/)\n\n\nSo the first thing you need in order to use this application is Node.js:\n\n[http://nodejs.org/](http://nodejs.org/)\n\nOnce installed, then install AS3JS as a global module via your command line:\n\n```\n$ npm install as3js -g\n```\n\nIf you just want to install as3js into a local project, you can omit the `-g` to run via `./node_modules/.bin/as3js`:\n\n```\n$ npm install as3js\n```\n\n## Usage ##\n\n### CLI ###\n\nAS3JS can be run as a CLI via the `as3js` command, which has the following parameters:\n\n`-o`, `--output`: Path where the output file will be written (e.g. path/to/output.js)\n\n`-src`, `--sourcepath`: Comma-delimited list of paths to pull source .as files from. It is expected that this path be the root of your project's package directory. So for example, if you defined a package such as `com.myproject`, you would want this value to be the folder that contains the `com` directory. Note that AS3JS processes folders recursively, so you only need to put the path to your top-level folders.\n\n`-h`, `--help`: Outputs help information.\n\n`-v`,`--version`: Outputs version information.\n\n`-s`,`--silent`: Flag to completely silence AS3JS output.\n\n`--verbose`: Flag to enable verbose output. Use to help debug transpiler errors.\n\n`-d`, `--dry`: Perfoms a dry-run of the compilation. This will perform all of the usual compilation steps but skip writing the final output file.\n\n`-e`, `--entry`: This is the entry package class for your application. Uses the format `[mode]:path.to.package.Class`. You replace `[mode]` with either `\"instance\"` to have AS3JS instantiate the class once your compiled script loads, or `\"static\"` to have AS3JS return the class function as-is.\n\n`--safe-require` - Puts a try-catch around require statements. Useful for code that may run in both the browser and Node.js\n\n`--ignore-flash` - Ignores imports of flash.* packages (helps silence errors when porting Flash code)\n\nHere is an example command:\n\n```\n$ as3js -src ./myas3 -o ./output.js -e new:com.example.MyClass\n```\n\nThe above example recursively browses through the directory `myas3` finding all `.as` files, converts them to JS, and finally combines the results into a file called `output.js` in the working directory. This script contains your entire application, and will initialize `MyClass` as your entry point.  Simple as that!\n### Node Script ###\n\nAS3JS can also be initialized manually within a Node.js script like so:\n\n```js\n// Import the compiler\nvar AS3JS = require('as3js');\n\n// Instantiate the compiler\nvar as3js = new AS3JS();\nvar result = as3js.compile({\n  srcPaths: ['./src'], // --sourcepath\n  silent: false, // --silent\n  verbose: false, // --verbose\n  entry: \"com.my.App\", // Entry point class path\n  entryMode: \"instance\", // \"instance\" or \"static\"\n  safeRequire: false, // --safe-require\n  ignoreFlash: false // --ignore-flash\n  packages: [] // Provide an array of raw text strings to be parsed as \"files\"\n});\n\n// Gets the compiled source text and do what you want with it\nvar sourceText = result.compiledSource;\n\n// Example: Prepending the loader source code to the program\nvar as3jslib = fs.readFileSync('node_modules/as3js/lib/as3.js');\nfs.writeFileSync('app.js', as3jslib + '\\n' + sourceText, \"UTF-8\", {flags: 'w+'});\n```\n\n\n\n## Examples ##\n\n- **[Live browser demo](https://jsfiddle.net/cleod9/r1kn2cxf/12/embedded/result)** - Test out AS3JS right in your browser!\n\n- **[Elevator Engine](https://github.com/cleod9/elevatorjs)** - I wrote this elevator simulator a long time ago in JavaScript and converted it to AS3. What's unique about this one is that the code can also compile to SWF simply by swapping out a single file.\n\n## Limitations ##\n\nOf course since AS3JS is still in alpha it comes with its limitations. See below:\n\n### Event Listeners ###\n\nAS3JS does not enforce class function binding when using them as callbacks. This is commonly an issue when dealing with event listeners. This simply means you will have to manage binding any event listeners on your own. A simple workaround for this is as follows:\n\n```actionscript\n//Write a global helper somewhere that anyone can access\nvar eventHelper = function (context, fn) {\n\t//Returns a function with the proper binding\n\treturn function () {\n\t\treturn fn.apply(context, Array.prototype.slice.call(arguments));\n\t};\n};\n```\n```actionscript\n//Usage in AS3\npackage {\n\tpublic class Main {\n\t\tpublic var myFuncBinded:Function;\n\t\tpublic function Main():void {\n\t\t\t//Allows you to use myFuncBinded for guaranteed scope\n\t\t\tmyFuncBinded = eventHelper(this, myFunc);\n\t\t\twindow.addEventListener(\"click\", myFuncBinded);\n\t\t}\n\t\tpublic function myFunc(e:* = null):void {\n\t\t\t//When window is clicked\n\t\t\tconsole.log(\"clicked\");\n\t\t}\n\t}\n}\n```\n### No True Privates ###\n\nWhile you can use any of the encapsulation keywords you'd like, there is currently no \"true\" encapsulation support in AS3JS. Private/protected class properties and methods remain publicly accessible on any instantiated objects. I gave a lot of thought to this and went over many potential solutions. I came to the conclusion that while encapsulation is convenient, in the open world of JavaScript all of this data is easily accessible through basic browser debugging tools. As such, I have no plans to add true encapsulation to AS3JS. The good news is that you can still use the keywords and AS3JS will simply strip them out.\n\n### No Chaining super() ###\n\nAS3JS does not currently support chaining `super` (i.e. `super.super.super.fn()`). If you need such a feature, you can achieve this by using JavaScript in your code:\n\n```actionscript\nGreatGrandfather.prototype.fn.call(this, arg1, arg2... etc);\n```\n\n### No type validation ###\n\nAS3JS will not validate your types during compile time or runtime. I may add some compile time type checking in the future, but there are no plans for runtime type checking due to unnecessary overhead.\n\n### Typed variable declarations cannot be all on one line ###\n\nI hope to work on this soon, but currently you can't write statements like this:\n\n```actionscript\nvar a:Type, b:Type, c:Type = 4;\n```\nIf you remove the types it will work fine, but I have not yet implemented anything to strip the types from this type of statement.\n\n### Class-level member variable assignments must be on one line ###\n\nCurrently AS3JS doesn't support breaking out something like this into separate lines:\n\n```actionscript\npublic static var foo:Object = { a: 1, b: 2, c: 3, d: 4, e: 5 };\n```\nHopefully you aren't writing such large assignments on class level properties, but for now please write these types of assignments as one-liners.\n\n### Getter/Setter limitations ###\n\nWhile the getter/setters work pretty well, there are a couple of things you should avoid:\n\n- Assigning a value to a setter that spans multiple lines;\n- Accessing a getter from within a getter: (e.g. `myGetter['key'].someOtherGetter`)\n\nAS3JS isn't able to recognize those situations, so it will likely export invalid JS.\n\n### No support for package-level functions ###\n\nThis isn't something I've seen used all that often anyway, but if you want to read up on package-level functions see [here](http://blogs.adobe.com/digitalmedia/2011/01/as3-package-level-functions-and-java-static-imports/)\n\n### No casting types ###\n\nI have not implemented the `as` operator, nor can you case with the `Caster(castee)` syntax. The only workaround for now is to re-assign values to a variable that has the proper Type:\n\n```actionscript\nvar other:SomeOtherType = new SomeOtherType();\nvar foo:TypeIWant = other;\n```\n\n### No `is` support ###\n\nCurrently there is no support for type checking via the `is` operator (e.g. `val is Type`) Just stick with `instanceof` for now.\n\n### No `Embed` support ###\n\nResource embedding is specific to the Flash platform, so I have no plans to implement it at this time.\n\n### Restricted regex support ###\n\nThe parser is currently unable to recognize the start and end of a regular expression literal (e.g. `/pattern/`). As such, characters such as `\"`, `'`, `{`, `}`, and other patterns may confuse the parser. A simple workaround for this is to use the `RegExp` constructor to define regular expressions that contain these characters (e.g. `new RegExp(\"pattern\")`)\n\n\n## \\*Disclaimer\\* ##\n\n**AS3JS cannot currently convert *all* AS3 to proper JS.** While I have put a ton of effort into allowing it to convert 99% of AS3 syntax into JavaScript, the languages are still fundamentally different. There are several things that I have yet to handle, such as casting via the `as` operator, or forcefully binding event callbacks to class instances. This tool is not perfect, however it is quite able to handle a full-fledged personal project. You'll find that  sometimes after compiling without errors there may still be some minor syntax issues in the output, however nearly all of these issues can be avoided very easily with a few code tweaks in your AS3 and are easy to catch (See \"Limitations\" listed above).\n\nAlso I would like to note that **this is not an all-in-one solution** like [FlashJS](http://flashjs.com/), [FlexJS](http://flex.apache.org/download-flexjs.html), [OpenFL](http://www.openfl.org/), or [Randori](http://randoriframework.com/). This is more like what [Jangaroo](http://www.jangaroo.net/home/) was meant to do, but a trillion times simpler. Although AS3JS can be used to create code that is somewhat cross-compatible with Flash, it is still designed with the average JavaScript developer in mind. The philosophy of AS3JS is to greatly simplify the organization of your JavaScript code using AS3 as syntax, not to re-create Flash. You have the freedom to implement Flash AS3 features if you want, but they will not come built into AS3JS.\n\nLastly, I fully acknowledge the ActionScript name as the property of [Adobe](http://www.adobe.com/). I do not claim ownership of the language nor do I have any affiliation with Adobe, but I do encourage you to check out the [documentation](http://www.adobe.com/devnet/actionscript/learning.html) if you are unfamiliar with ActionScript 3.0. Just remember that AS3JS is made for JavaScript, so many features of Flash AS3 will not be implemented unless you create them yourself.\n\n## Building Source ##\n\nThe source code for AS3JS is written in ActionScript 3 under the `src/` folder, and is also set up as a FlashDevelop project. You can compile the source code one of two ways:\n\n\n- Clicking the Build button in the toolbar of FlashDevelop\n\nOR\n\n- Executing `node build.js` via the command-line\n\nEither of these steps will output a file called `runtime-compiled.js`. Replace `runtime.js` with the contents of `runtime-compiled.js` to update the runtime with your changes.\n\n### Finalizing A Build ###\n\nSince AS3JS's source is written to be compiled by AS3JS itself, if your changes affect the output of compiled files it's important to run the build again and replace `runtime.js` a second AND third time. This ensures that the runtime is using your code as opposed to an outdated runtime. If something is wrong with the build, it will likely fail the third time you attempt to build. It also can't hurt to build a fourth time to ensure the final build is stable.\n\n\n## Upgrade Notes ##\n\n**Upgrading from v0.1.**: [ImportJS](https://github.com/Cleod9/importjs) and [OOPS.js](https://github.com/Cleod9/oopsjs) are no longer dependencies of this project, so be sure to follow the new setup instructions carefully)\n\n**Upgrading from v0.2.**: AS3JS's responsibilities have been split into two functions: The *compiler*, and the *loader*. The compiler is what converts your AS3 into vanilla JS, but with a few extra features that depend on a separate loader library included in this repo. In browser environments, this is just a matter of using the `./lib/as3.js` as a global script on the page to load your program. For Node.js environments, you'll need to attach AS3JS to the `global` object (details later on below)\n\n\n## Version History ##\n\n**0.3.3** (Final build)\n- Added $cinit() and $init() logic to mimic Flash\n- Inferring imports from top-scope member assignments\n\n**0.3.2**\n- Handle dictionary class\n- Const keyword Removal\n- Implicit Static Assignments\n\n**0.3.1**\n- Updated Readme\n- Improved error messaging when class paths are missing\n\n**0.3.0**\n\n- Documented the Node.js interface for loading the compiler manually\n- Split AS3JS roles into \"compiler\" and \"program\" (while still maintaining mostly vanilla code)\n- Added safeRequire option to allow browser to load code with Node require statements\n- Added ignoreFlash option to ignore **flash.*** packages\n- Fixed several issues with transpiling classes in the top-level package\n- Experimental package-level `require` feature\n- New `packages` option that can be used when compiling directly in Node.js (allows injecting raw text packages into the compiler)\n- Shipped new live editor with 0.3.* support: https://jsfiddle.net/cleod9/r1kn2cxf/12/embedded/result\n\n**0.2.***\n\n-Created new Vanilla output format that no longer requires external libraries\n-Removed ImportJS and OOPS.js as dependencies\n\n**0.1.***\n\n-Initial alpha release\n\n**0.0.1**\n\n-First commit (before conversion of the source code itself to AS3)\n\n\n\n----------\n\nCopyrighted © 2017 by Greg McLeod\n\nGitHub: [https://github.com/cleod9](https://github.com/cleod9)"
  },
  {
    "path": "bin/as3jsc.js",
    "content": "#!/usr/bin/env node\n\n/**\n* This is the global AS3JS compiler for running 'as3js' as a CLI\n**/\n\nvar pjson = require('../package.json');\nvar fs = require('fs');\nvar path = require('path');\nglobal.AS3JS = require(path.resolve(__dirname, '..', 'lib/as3.js'));\nvar AS3JS = require(path.resolve(__dirname, '..', 'runtime.js'));\n\nvar VERSION = pjson.version;\n\n//AS3JS options\nvar srcPaths = [];\nvar output = null;\nvar silent = false;\nvar verbose = false;\nvar entry = '';\nvar dry = false;\nvar safeRequire = false;\nvar ignoreFlash = false;\n\n//Command line args\nvar arg = null;\nvar option = null;\nvar command = null;\n\n//Misc options\n\n//Parse arguemnts\nfor(var i = 0; i < process.argv.length; i++) {\n\targ = process.argv[i];\n\tif(command) {\n\t\t//Commands will go here if implemented\n\t\tcommand = null;\n\t} else if(option) {\n\t\t//Options are set here\n\t\tif(option == 'o') {\n\t\t\toutput = arg; //File output\n\t\t} else if(option == 'src') {\n\t\t\tsrcPaths = srcPaths.concat(arg.split(\",\")); //Source path(s) to parse\n\t\t} else if(option == 'e') {\n\t\t\tentry = arg;\n\t\t}\n\t\toption = null;\n\t} else {\n\t\tif(arg == '--verbose') {\n\t\t\tverbose = true;\n\t\t} else if(arg == '-d' || arg == '--dry') {\n\t\t\tdry = true;\n\t\t} else if(arg == '-s' || arg == '--silent') {\n\t\t\tsilent = true;\n\t\t} else if(arg == '--safe-require') {\n\t\t\tsafeRequire = true;\n\t\t} else if(arg == '-o' || arg == '--output') {\n\t\t\toption = 'o'; //File output\n\t\t} else if(arg == '-src' || arg == '--sourcepath') {\n\t\t\toption = 'src'; //Source path(s)\n\t\t} else if(arg == '-e' || arg == '--entry') {\n\t\t\toption = 'e'; //Entry point\n\t\t} else if(arg == '--ignore-flash') {\n\t\t\tignoreFlash = true;\n\t\t} else if(arg == '-h' || arg == '--help') {\n\t\t\t//Help text\n\t\t\tconsole.log(\"Options:\");\n\t\t\tconsole.log(\"\\t[-o|--output]\\t\\tOutput file\");\n\t\t\tconsole.log(\"\\t[-src|-sourcepath]\\tSource Path(s) (comma-separated)\");\n\t\t\tconsole.log(\"\\t[-d|--dry]\\tDry-run mode\");\n\t\t\tconsole.log(\"\\t[-e|--entry]\\t\\tEntry point (ex. \\\"[instance|static]:com.example.MyClass\\\")\");\n\t\t\tconsole.log(\"\\t[-h|--help]\\t\\tView Help\");\n\t\t\tconsole.log(\"\\t[-v|--version]\\t\\tView Version information\");\n\t\t\tconsole.log(\"\\t[--verbose]\\t\\tVerbose console output\");\n\t\t\tconsole.log(\"\\t[--safe-require]\\t\\tTry-catch require() statements\");\n\t\t\tconsole.log(\"\\t[--ignore-flash]\\t\\tIgnore flash.* imports\");\n\t\t\t\n\t\t\treturn;\n\t\t} else if(arg == '-v' || arg == '--version') {\n\t\t\t//Version info\n\t\t\tconsole.log(\"AS3JS for Node.js\");\n\t\t\tconsole.log(\"Created by Greg McLeod (c) 2017\");\n\t\t\tconsole.log(\"Version: \" + VERSION);\n\t\t\treturn;\n\t\t}\n\t}\n}\n\nif(srcPaths.length <= 0) {\n\tconsole.log(\"Error, must supply source path (-src)\");\n} else if(!output) {\n\tconsole.log(\"Error, must supply output path (-o)\");\n} else {\n\tvar as3js = new AS3JS();\n\tvar sourceText = as3js.compile({\n\t\tsrcPaths: srcPaths,\n\t\tsilent: silent,\n\t\tverbose: verbose,\n\t\tentry: entry.split(':')[1],\n\t\tentryMode: entry.split(':')[0],\n\t\tsafeRequire: safeRequire,\n\t\tignoreFlash: ignoreFlash\n\t}).compiledSource;\n\t\n\t//Remove old output file if it exists\n\tif (output && !dry)\n\t{\n\t\tif (fs.existsSync(output))\n\t\t{\n\t\t\tfs.unlinkSync(output);\n\t\t}\n\t\tfs.writeFileSync(output || 'output.js', sourceText, \"UTF-8\", {flags: 'w+'});\n\t}\n}\n"
  },
  {
    "path": "build.js",
    "content": "var fs = require('fs');\nvar beautify = require('js-beautify').js_beautify;\n// Pull in loader library first\nglobal.AS3JS = require('./lib/as3.js');\n// Now Pull in the actual AS3JS program\nvar AS3JS = require('./runtime.js');\n\n// Load the program\nvar as3js = new AS3JS();\n\n// Execute the program \nvar sourceText = as3js.compile({\n\tsrcPaths: ['./src'],\n\tsilent: false,\n\tverbose: false,\n\tsafeRequire: true,\n\tentry: 'com.mcleodgaming.as3js.Main',\n\tentryMode: 'static'\n}).compiledSource;\n\n// Output the resulting source code\nif (fs.existsSync('runtime-compiled.js'))\n{\n\tfs.unlinkSync('runtime-compiled.js');\n}\nfs.writeFileSync('runtime-compiled.js', beautify(sourceText, { indent_size: 2, max_preserve_newlines: 2 }), \"UTF-8\", {flags: 'w+'});"
  },
  {
    "path": "index.js",
    "content": "global.AS3JS = require('./lib/as3.js');\n\nmodule.exports = require('./runtime.js');"
  },
  {
    "path": "lib/as3.js",
    "content": "/*******************************\n  AS3JS Version 0.3.3\n  \n    AS3 to JS converter for use with ImportJS and OOPS.js.\n  \n  The MIT License (MIT)\n\n  Copyright (c) 2017 Greg McLeod <cleod9{at}gmail.com>\n\n  Permission is hereby granted, free of charge, to any person obtaining a copy\n  of this software and associated documentation files (the \"Software\"), to deal\n  in the Software without restriction, including without limitation the rights\n  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n  copies of the Software, and to permit persons to whom the Software is\n  furnished to do so, subject to the following conditions:\n\n  The above copyright notice and this permission notice shall be included in\n  all copies or substantial portions of the Software.\n\n  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n  THE SOFTWARE.\n*******************************/\n(function ( ) {\n  var AS3JS = {\n    Utils: {\n      // Helper for default args\n      getDefaultValue: function getDefaultValue(value, fallback) {\n        return (typeof value != 'undefined') ? value : fallback;\n      },\n      // Helper for Vector/Array constructors\n\t  createArray: function (size, val) {\n        var arr = [];\n        for (var i = 0; i < size; i++)  {\n          arr.push(val); \n        }\n        return arr;\n      }\n    },\n    load: function ( params ) {\n      // Loads program specified by params\n      params = params || {};\n\t  params.entryMode = params.entryMode || 'instance';\n\t\n      // Shim just in case\n      if (typeof Object.create !== 'function') {\n        Object.create = function (o) {\n          function F() {}\n          F.prototype = o;\n          return new F();\n        }\n      };\n\n      // Some temps / helper\n      var i, j, tmpPkg;\n      var getPackageInfo = function ( name ) {\n        // Splits package path into separate package and class name\n        var pkg = name.split('.');\n        var className = pkg[pkg.length-1];\n        pkg.splice(pkg.length-1, 1);\n        var packageName = pkg.join('.');\n\n        return { \n          packageName: packageName,\n          className: className\n        };\n      };\n\n      // This hash map contains each package, each package contains its classes\n      var packages = {};\n\n      // Converts supplied package hash to packageName.className.{ source: moduleFn }\n      for (i in params.program) {\n        tmpPkg = getPackageInfo(i);\n        packages[tmpPkg.packageName] = packages[tmpPkg.packageName] || {};\n        packages[tmpPkg.packageName][tmpPkg.className] = { compiled: false, source: params.program[i] };\n      }\n\n      // This helper will execute the module source specified by \"name\" and return its exports object\n      var imports = function ( packageName, className ) {\n        // Only run source() if it hasn't been compiled yet\n        if (!packages[packageName][className].compiled) {\n          packages[packageName][className].compiled = true;\n          packages[packageName][className].module = { exports: null, inject: null, import: imports };\n          //This next line actually compiles the module\n          packages[packageName][className].source(packages[packageName][className].module, packages[packageName][className].module.exports);\n        }\n        // Returns the compiled module\n        return packages[packageName][className].module.exports;\n      };\n\n      // Compiles all packages\n      for (i in packages) {\n        for (j in packages[i]) {\n          imports(i, j);\n        }\n      }\n\t\n      // Run inject() and $cinit() functions as the final step (this trivializes circular dependencies)\n      for (i in packages) {\n        // Execute the injection functions\n        for (j in packages[i]) {\n          if (typeof packages[i][j].module.inject === 'function') {\n            packages[i][j].module.inject();\n          }\n        }\n      }\n      for (i in packages) {\n        // Execute the $cinit functions\n        for (j in packages[i]) {\n          if (typeof packages[i][j].module.exports.$cinit === 'function') {\n            packages[i][j].module.exports.$cinit();\n          }\n        }\n      }\n\n      // Initializes application\n      var entryPkgInfo = getPackageInfo(params.entry);\n      var entryPoint = imports(entryPkgInfo.packageName, entryPkgInfo.className);\n      if (params.entryMode === \"instance\") {\n        return new entryPoint();\n      } else if (params.entryMode === \"static\") {\n        return entryPoint;\n      }\n    }\n  };\n  \n  if (typeof module !== 'undefined') {\n    //CommonJS\n    module.exports = AS3JS;\n  } else {\n    //Browser Global\n    window.AS3JS = AS3JS;\n  }\n})();"
  },
  {
    "path": "package.json",
    "content": "{\n\t\"name\": \"as3js\",\n\t\"version\": \"0.3.3\",\n\t\"author\": \"Greg McLeod <cleod9@gmail.com>\",\n\t\"description\": \"AS3 to JS converter.\",\n\t\"bin\": {\n\t\t\"as3js\": \"./bin/as3jsc.js\"\n\t},\n\t\"devDependencies\": {\n\t\t\"js-beautify\": \"1.5.10\"\n\t},\n\t\"main\": \"./index.js\",\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"https://github.com/cleod9/as3js\"\n\t},\n\t\"keywords\": [\n\t\t\"as3\",\n\t\t\"js\",\n\t\t\"converter\",\n\t\t\"import\",\n\t\t\"oop\"\n\t],\n\t\"license\": \"MIT\"\n}\n"
  },
  {
    "path": "runtime.js",
    "content": "(function() {\n  var Program = {};\n  Program[\"com.mcleodgaming.as3js.enums.AS3Encapsulation\"] = function(module, exports) {\n    var AS3Encapsulation = function AS3Encapsulation() {};\n\n    AS3Encapsulation.PUBLIC = null;\n    AS3Encapsulation.PRIVATE = null;\n    AS3Encapsulation.PROTECTED = null;\n\n    AS3Encapsulation.$cinit = function() {\n      AS3Encapsulation.PUBLIC = \"public\";\n      AS3Encapsulation.PRIVATE = \"private\";\n      AS3Encapsulation.PROTECTED = \"protected\";\n\n    };\n\n    AS3Encapsulation.prototype.$init = function() {}\n\n    module.exports = AS3Encapsulation;\n  };\n  Program[\"com.mcleodgaming.as3js.enums.AS3MemberType\"] = function(module, exports) {\n    var AS3MemberType = function AS3MemberType() {};\n\n    AS3MemberType.VAR = null;\n    AS3MemberType.CONST = null;\n    AS3MemberType.FUNCTION = null;\n\n    AS3MemberType.$cinit = function() {\n      AS3MemberType.VAR = \"var\";\n      AS3MemberType.CONST = \"const\";\n      AS3MemberType.FUNCTION = \"function\";\n\n    };\n\n    AS3MemberType.prototype.$init = function() {}\n\n    module.exports = AS3MemberType;\n  };\n  Program[\"com.mcleodgaming.as3js.enums.AS3ParseState\"] = function(module, exports) {\n    var AS3ParseState = function AS3ParseState() {};\n\n    AS3ParseState.START = null;\n    AS3ParseState.PACKAGE_NAME = null;\n    AS3ParseState.PACKAGE = null;\n    AS3ParseState.CLASS_NAME = null;\n    AS3ParseState.CLASS = null;\n    AS3ParseState.CLASS_EXTENDS = null;\n    AS3ParseState.CLASS_IMPLEMENTS = null;\n    AS3ParseState.COMMENT_INLINE = null;\n    AS3ParseState.COMMENT_MULTILINE = null;\n    AS3ParseState.STRING_SINGLE_QUOTE = null;\n    AS3ParseState.STRING_DOUBLE_QUOTE = null;\n    AS3ParseState.STRING_REGEX = null;\n    AS3ParseState.MEMBER_VARIABLE = null;\n    AS3ParseState.MEMBER_FUNCTION = null;\n    AS3ParseState.LOCAL_VARIABLE = null;\n    AS3ParseState.LOCAL_FUNCTION = null;\n    AS3ParseState.IMPORT_PACKAGE = null;\n    AS3ParseState.REQUIRE_MODULE = null;\n\n    AS3ParseState.$cinit = function() {\n      AS3ParseState.START = \"start\";\n      AS3ParseState.PACKAGE_NAME = \"packageName\";\n      AS3ParseState.PACKAGE = \"package\";\n      AS3ParseState.CLASS_NAME = \"className\";\n      AS3ParseState.CLASS = \"class\";\n      AS3ParseState.CLASS_EXTENDS = \"classExtends\";\n      AS3ParseState.CLASS_IMPLEMENTS = \"classImplements\";\n      AS3ParseState.COMMENT_INLINE = \"commentInline\";\n      AS3ParseState.COMMENT_MULTILINE = \"commentMultiline\";\n      AS3ParseState.STRING_SINGLE_QUOTE = \"stringSingleQuote\";\n      AS3ParseState.STRING_DOUBLE_QUOTE = \"stringDoubleQuote\";\n      AS3ParseState.STRING_REGEX = \"stringRegex\";\n      AS3ParseState.MEMBER_VARIABLE = \"memberVariable\";\n      AS3ParseState.MEMBER_FUNCTION = \"memberFunction\";\n      AS3ParseState.LOCAL_VARIABLE = \"localVariable\";\n      AS3ParseState.LOCAL_FUNCTION = \"localFunction\";\n      AS3ParseState.IMPORT_PACKAGE = \"importPackage\";\n      AS3ParseState.REQUIRE_MODULE = \"requireModule\";\n\n    };\n\n    AS3ParseState.prototype.$init = function() {}\n\n    module.exports = AS3ParseState;\n  };\n  Program[\"com.mcleodgaming.as3js.enums.AS3Pattern\"] = function(module, exports) {\n    var AS3Pattern = function AS3Pattern() {};\n\n    AS3Pattern.IDENTIFIER = null;\n    AS3Pattern.OBJECT = null;\n    AS3Pattern.IMPORT = null;\n    AS3Pattern.REQUIRE = null;\n    AS3Pattern.CURLY_BRACE = null;\n    AS3Pattern.VARIABLE = null;\n    AS3Pattern.VARIABLE_TYPE = null;\n    AS3Pattern.VARIABLE_DECLARATION = null;\n    AS3Pattern.ASSIGN_START = null;\n    AS3Pattern.ASSIGN_UPTO = null;\n    AS3Pattern.VECTOR = null;\n    AS3Pattern.ARRAY = null;\n    AS3Pattern.DICTIONARY = null;\n    AS3Pattern.REST_ARG = null;\n\n    AS3Pattern.$cinit = function() {\n      AS3Pattern.IDENTIFIER = [/\\w/g, /\\w/g];\n      AS3Pattern.OBJECT = [/[\\w\\.]/g, /[\\w(\\w(\\.\\w)+)]/g];\n      AS3Pattern.IMPORT = [/[0-9a-zA-Z_$.*]/g, /[a-zA-Z_$][0-9a-zA-Z_$]([.][a-zA-Z_$][0-9a-zA-Z_$])*\\*?/g];\n      AS3Pattern.REQUIRE = [/./g, /[\"'](.*?)['\"]/g];\n      AS3Pattern.CURLY_BRACE = [/[\\{|\\}]/g, /[\\{|\\}]/g];\n      AS3Pattern.VARIABLE = [/[0-9a-zA-Z_$]/g, /[a-zA-Z_$][0-9a-zA-Z_$]*/g];\n      AS3Pattern.VARIABLE_TYPE = [/[a-zA-Z_$<>.*][0-9a-zA-Z_$<>.]*/g, /[a-zA-Z_$<>.*][0-9a-zA-Z_$<>.]*/g];\n      AS3Pattern.VARIABLE_DECLARATION = [/[0-9a-zA-Z_$:<>.*]/g, /[a-zA-Z_$][0-9a-zA-Z_$]*\\s*:\\s*([a-zA-Z_$<>\\.\\*][0-9a-zA-Z_$<>\\.]*)/g];\n      AS3Pattern.ASSIGN_START = [/[=\\r\\n]/g, /[=\\r\\n]/g];\n      AS3Pattern.ASSIGN_UPTO = [new RegExp(\"[^;\\\\r\\\\n]\", \"g\"), /(.*?)/g];\n      AS3Pattern.VECTOR = [/new[\\s\\t]+Vector\\.<(.*?)>\\((.*?)\\)/g, /new[\\s\\t]+Vector\\.<(.*?)>\\((.*?)\\)/];\n      AS3Pattern.ARRAY = [/new[\\s\\t]+Array\\((.*?)\\)/g, /new[\\s\\t]+Array\\((.*?)\\)/];\n      AS3Pattern.DICTIONARY = [/new[\\s\\t]+Dictionary\\((.*?)\\)/g];\n      AS3Pattern.REST_ARG = [/\\.\\.\\.[a-zA-Z_$][0-9a-zA-Z_$]*/g, /\\.\\.\\.[a-zA-Z_$][0-9a-zA-Z_$]*/g];\n\n    };\n\n    AS3Pattern.prototype.$init = function() {}\n\n    module.exports = AS3Pattern;\n  };\n  Program[\"com.mcleodgaming.as3js.Main\"] = function(module, exports) {\n    var path = (function() {\n      try {\n        return require(\"path\");\n      } catch (e) {\n        return undefined;\n      }\n    })();\n    var fs = (function() {\n      try {\n        return require(\"fs\");\n      } catch (e) {\n        return undefined;\n      }\n    })();\n\n    var AS3Parser;\n    module.inject = function() {\n      AS3Parser = module.import('com.mcleodgaming.as3js.parser', 'AS3Parser');\n    };\n\n    var Main = function() {\n      this.$init();\n\n    };\n\n    Main.DEBUG_MODE = false;\n    Main.SILENT = false;\n    Main.debug = function() {\n      if (Main.SILENT) {\n        return;\n      }\n      if (Main.DEBUG_MODE) {\n        console.log.apply(console, arguments);\n      }\n    };\n    Main.log = function() {\n      if (Main.SILENT) {\n        return;\n      }\n      console.log.apply(console, arguments);\n    };\n    Main.warn = function() {\n      if (Main.SILENT) {\n        return;\n      }\n      console.warn.apply(console, arguments);\n    };\n\n    Main.$cinit = function() {\n      Main.DEBUG_MODE = false;\n      Main.SILENT = false;\n\n    };\n\n    Main.prototype.$init = function() {};\n    Main.prototype.compile = function(options) {\n      options = AS3JS.Utils.getDefaultValue(options, null);\n      var packages = {}; //Will contain the final map of package names to source text\n      var i;\n      var j;\n      var k;\n      var m;\n      var tmp;\n      options = options || {};\n      var srcPaths = options.srcPaths || {};\n      var rawPackages = options.rawPackages || [];\n      var parserOptions = {\n        safeRequire: options.safeRequire,\n        ignoreFlash: options.ignoreFlash\n      };\n\n      //Temp classes for holding raw class info\n      var rawClass;\n      var rawParser;\n\n      var pkgLists = {};\n      for (i in srcPaths) {\n        pkgLists[srcPaths[i]] = this.buildPackageList(srcPaths[i]);\n      }\n\n      Main.DEBUG_MODE = options.verbose || Main.DEBUG_MODE;\n      Main.SILENT = options.silent || Main.SILENT;\n\n      var classes = {};\n      var buffer = \"\";\n\n      //First, parse through the file-based classes and get the basic information\n      for (i in pkgLists) {\n        for (j in pkgLists[i]) {\n          Main.log('Analyzing class path: ' + pkgLists[i][j].classPath);\n          classes[pkgLists[i][j].classPath] = pkgLists[i][j].parse(parserOptions);\n          Main.debug(classes[pkgLists[i][j].classPath]);\n        }\n      }\n\n      // Now parse through any raw string classes\n      for (i = 0; i < rawPackages.length; i++) {\n        Main.log('Analyzing class: ' + i);\n        rawParser = new AS3Parser(rawPackages[i]);\n        rawClass = rawParser.parse(parserOptions);\n        classes[rawParser.classPath] = rawClass;\n      }\n\n      //Resolve all possible package name wildcards\n      for (i in classes) {\n        //For every class\n        for (j in classes[i].importWildcards) {\n          Main.debug('Resolving ' + classes[i].className + '\\'s ' + classes[i].importWildcards[j] + ' ...')\n            //For every wild card in the class\n          for (k in srcPaths) {\n            //For each possible source path (should hopefully just be 1 most of the time -_-)\n            tmp = srcPaths[k] + path.sep + classes[i].importWildcards[j].replace(/\\./g, path.sep).replace(path.sep + '*', '');\n            tmp = tmp.replace(/\\\\/g, '/');\n            tmp = tmp.replace(/[\\/]/g, path.sep);\n            if (fs.existsSync(tmp)) {\n              Main.debug('Searching path ' + tmp + '...')\n                //Path exists, read the files in the directory\n              var files = fs.readdirSync(tmp);\n              for (m in files) {\n                //See if this is an ActionScript file\n                if (fs.statSync(tmp + path.sep + files[m]).isFile() && files[m].lastIndexOf('.as') == files[m].length - 3) {\n                  //See if the class needs the file\n                  if (classes[i].needsImport(classes[i].importWildcards[j].replace(/\\*/g, files[m].substr(0, files[m].length - 3)))) {\n                    Main.debug('Auto imported ' + files[m].substr(0, files[m].length - 3));\n                    classes[i].addImport(classes[i].importWildcards[j].replace(/\\*/g, files[m].substr(0, files[m].length - 3))); //Pass in package name with wild card replaced\n                  }\n                }\n              }\n            } else {\n              Main.warn('Warning, could not find directory: ' + tmp);\n            }\n          }\n          // Must do again for classes in case there we\n          for (k in classes) {\n            if (classes[i].needsImport(AS3Parser.fixClassPath(classes[k].packageName + '.' + classes[k].className))) {\n              Main.debug('Auto imported ' + AS3Parser.fixClassPath(classes[k].packageName + '.' + classes[k].className));\n              classes[i].addImport(AS3Parser.fixClassPath(classes[k].packageName + '.' + classes[k].className)); //Pass in package name with wild card replaced\n            }\n          }\n        }\n      }\n\n      //Add extra imports before registring them (these will not be imported in the output code, but rather will provide insight for AS3JS to determine variable types)\n      for (i in classes) {\n        for (j in classes) {\n          classes[i].addExtraImport(AS3Parser.fixClassPath(classes[j].packageName + '.' + classes[j].className));\n        }\n      }\n\n      //Resolve import map\n      for (i in classes) {\n        classes[i].registerImports(classes);\n      }\n\n      //Resolve parent imports\n      for (i in classes) {\n        classes[i].findParents(classes);\n      }\n\n      //Walk through the class members that had assignments in the class scope\n      for (i in classes) {\n        classes[i].checkMembersWithAssignments();\n      }\n\n      //Process the function text to comply with JS\n      for (i in classes) {\n        Main.log('Parsing package: ' + AS3Parser.fixClassPath(classes[i].packageName + \".\" + classes[i].className));\n        classes[i].process(classes);\n      }\n      // Load stringified versions of snippets/main-snippet.js and snippets/class-snippet.js\n      var mainTemplate = \"(function(){var Program={};{{packages}}if(typeof module !== 'undefined'){module.exports=AS3JS.load({program:Program,entry:\\\"{{entryPoint}}\\\",entryMode:\\\"{{entryMode}}\\\"});}else if(typeof window!=='undefined'&&typeof AS3JS!=='undefined'){window['{{entryPoint}}']=AS3JS.load({program:Program,entry:\\\"{{entryPoint}}\\\",entryMode:\\\"{{entryMode}}\\\"});}})();\";\n      var classTemplate = \"Program[\\\"{{module}}\\\"]=function(module, exports){{{source}}};\";\n      var packageObjects = [];\n      var classObjects = null;\n      var currentClass = \"\";\n\n      if (options.entry) {\n        // Entry point should be in the format \"mode:path.to.package.Class\"\n        var currentPackage = options.entry;\n        var mode = options.entryMode || 'instance';\n        // Update template with entry points\n        mainTemplate = mainTemplate.replace(/\\{\\{entryPoint\\}\\}/g, AS3Parser.fixClassPath(classes[currentPackage].packageName + '.' + classes[currentPackage].className));\n        mainTemplate = mainTemplate.replace(/\\{\\{entryMode\\}\\}/g, mode);\n      } else {\n        mainTemplate = mainTemplate.replace(/\\{\\{entryPoint\\}\\}/g, \"\");\n        mainTemplate = mainTemplate.replace(/\\{\\{entryMode\\}\\}/g, \"\");\n      }\n\n      //Retrieve converted class code\n      var groupByPackage = {};\n      for (i in classes) {\n        groupByPackage[classes[i].packageName] = groupByPackage[classes[i].packageName] || [];\n        groupByPackage[classes[i].packageName].push(classes[i]);\n      }\n      for (i in groupByPackage) {\n        classObjects = [];\n        for (j in groupByPackage[i]) {\n          packages[AS3Parser.fixClassPath(i + \".\" + groupByPackage[i][j].className)] = groupByPackage[i][j].toString();\n          currentClass = classTemplate;\n          currentClass = currentClass.replace(/\\{\\{module\\}\\}/g, AS3Parser.fixClassPath(groupByPackage[i][j].packageName + \".\" + groupByPackage[i][j].className));\n          currentClass = currentClass.replace(/\\{\\{source\\}\\}/g, AS3Parser.increaseIndent(packages[AS3Parser.fixClassPath(i + \".\" + groupByPackage[i][j].className)], \"  \"));\n          classObjects.push(currentClass);\n        }\n        packageObjects.push(AS3Parser.increaseIndent(classObjects.join(\"\"), \"  \"));\n      }\n\n      mainTemplate = mainTemplate.replace(/\\{\\{packages\\}\\}/g, packageObjects.join(\"\"));\n\n      mainTemplate = mainTemplate.replace(/\\t/g, \"  \");\n\n      buffer += mainTemplate;\n\n      Main.log(\"Done.\");\n\n      return {\n        compiledSource: buffer,\n        packageSources: packages\n      };\n    };\n    Main.prototype.readDirectory = function(location, pkgBuffer, obj) {\n      var files = fs.readdirSync(location);\n      for (var i in files) {\n        var pkg = pkgBuffer;\n        if (fs.statSync(location + path.sep + files[i]).isDirectory()) {\n          var splitPath = location.split(path.sep);\n          if (pkg != '') {\n            pkg += '.';\n          }\n          this.readDirectory(location + path.sep + files[i], pkg + files[i], obj)\n        } else if (fs.statSync(location + path.sep + files[i]).isFile() && files[i].lastIndexOf('.as') == files[i].length - 3) {\n          if (pkg != '') {\n            pkg += '.';\n          }\n          pkg += files[i].substr(0, files[i].length - 3);\n          var f = fs.readFileSync(location + path.sep + files[i]);\n          obj[pkg] = new AS3Parser(f.toString(), pkg);\n          Main.debug(\"Loaded file: \", location + path.sep + files[i] + \" (package: \" + pkg + \")\");\n        }\n      }\n    };\n    Main.prototype.buildPackageList = function(location) {\n      var obj = {};\n      var topLevel = location;\n      location = location.replace(/\\\\/g, '/');\n      location = location.replace(/[\\/]/g, path.sep);\n      if (fs.existsSync(location) && fs.statSync(location).isDirectory()) {\n        var splitPath = location.split(path.sep);\n        this.readDirectory(location, '', obj);\n        return obj;\n      } else {\n        throw new Error(\"Error could not find directory: \" + location);\n      }\n    }\n\n    module.exports = Main;\n  };\n  Program[\"com.mcleodgaming.as3js.parser.AS3Class\"] = function(module, exports) {\n    var Main, AS3Parser, AS3MemberType, AS3Pattern, AS3Function, AS3Variable;\n    module.inject = function() {\n      Main = module.import('com.mcleodgaming.as3js', 'Main');\n      AS3Parser = module.import('com.mcleodgaming.as3js.parser', 'AS3Parser');\n      AS3MemberType = module.import('com.mcleodgaming.as3js.enums', 'AS3MemberType');\n      AS3Pattern = module.import('com.mcleodgaming.as3js.enums', 'AS3Pattern');\n      AS3Function = module.import('com.mcleodgaming.as3js.types', 'AS3Function');\n      AS3Variable = module.import('com.mcleodgaming.as3js.types', 'AS3Variable');\n    };\n\n    var AS3Class = function(options) {\n      this.$init();\n      options = AS3JS.Utils.getDefaultValue(options, null);\n      options = options || {};\n      this.safeRequire = false;\n\n      if (typeof options.safeRequire !== 'undefined') {\n        this.safeRequire = options.safeRequire;\n      }\n      if (typeof options.ignoreFlash !== 'undefined') {\n        this.ignoreFlash = options.ignoreFlash;\n      }\n\n      this.packageName = null;\n      this.className = null;\n      this.imports = [];\n      this.requires = [];\n      this.importWildcards = [];\n      this.importExtras = [];\n      this.interfaces = [];\n      this.parent = null;\n      this.parentDefinition = null;\n      this.members = [];\n      this.staticMembers = [];\n      this.getters = [];\n      this.setters = [];\n      this.staticGetters = [];\n      this.staticSetters = [];\n      this.membersWithAssignments = [];\n      this.isInterface = false;\n      this.fieldMap = {};\n      this.staticFieldMap = {};\n      this.classMap = {};\n      this.classMapFiltered = {};\n      this.packageMap = {};\n\n      var $init = new AS3Function();\n      $init.name = \"$init\";\n      $init.value = \"{}\";\n      $init.type === AS3MemberType.FUNCTION;\n      $init.isStatic = false;\n      this.members.push($init);\n      this.registerField($init.name, $init);\n    };\n\n    AS3Class.reservedWords = null;\n    AS3Class.nativeTypes = null;\n\n    AS3Class.$cinit = function() {\n      AS3Class.reservedWords = [\"as\", \"class\", \"delete\", \"false\", \"if\", \"instanceof\", \"native\", \"private\", \"super\", \"to\", \"use\", \"with\", \"break\", \"const\", \"do\", \"finally\", \"implements\", \"new\", \"protected\", \"switch\", \"true\", \"var\", \"case\", \"continue\", \"else\", \"for\", \"import\", \"internal\", \"null\", \"public\", \"this\", \"try\", \"void\", \"catch\", \"default\", \"extends\", \"function\", \"in\", \"is\", \"package\", \"return\", \"throw\", \"typeof\", \"while\", \"each\", \"get\", \"set\", \"namespace\", \"include\", \"dynamic\", \"final\", \"natiev\", \"override\", \"static\", \"abstract\", \"char\", \"export\", \"long\", \"throws\", \"virtual\", \"boolean\", \"debugger\", \"float\", \"prototype\", \"to\", \"volatile\", \"byte\", \"double\", \"goto\", \"short\", \"transient\", \"cast\", \"enum\", \"intrinsic\", \"synchronized\", \"type\"];\n      AS3Class.nativeTypes = [\"Boolean\", \"Number\", \"int\", \"uint\", \"String\"];\n\n    };\n\n    AS3Class.prototype.$init = function() {\n      this.imports = null;\n      this.requires = null;\n      this.importWildcards = null;\n      this.importExtras = null;\n      this.interfaces = null;\n      this.parentDefinition = null;\n      this.members = null;\n      this.staticMembers = null;\n      this.getters = null;\n      this.setters = null;\n      this.staticGetters = null;\n      this.staticSetters = null;\n      this.membersWithAssignments = null;\n      this.fieldMap = null;\n      this.staticFieldMap = null;\n      this.classMap = null;\n      this.classMapFiltered = null;\n      this.packageMap = null;\n    };\n    AS3Class.prototype.packageName = null;\n    AS3Class.prototype.className = null;\n    AS3Class.prototype.imports = null;\n    AS3Class.prototype.requires = null;\n    AS3Class.prototype.importWildcards = null;\n    AS3Class.prototype.importExtras = null;\n    AS3Class.prototype.interfaces = null;\n    AS3Class.prototype.parent = null;\n    AS3Class.prototype.parentDefinition = null;\n    AS3Class.prototype.members = null;\n    AS3Class.prototype.staticMembers = null;\n    AS3Class.prototype.getters = null;\n    AS3Class.prototype.setters = null;\n    AS3Class.prototype.staticGetters = null;\n    AS3Class.prototype.staticSetters = null;\n    AS3Class.prototype.isInterface = false;\n    AS3Class.prototype.membersWithAssignments = null;\n    AS3Class.prototype.fieldMap = null;\n    AS3Class.prototype.staticFieldMap = null;\n    AS3Class.prototype.classMap = null;\n    AS3Class.prototype.classMapFiltered = null;\n    AS3Class.prototype.packageMap = null;\n    AS3Class.prototype.safeRequire = false;\n    AS3Class.prototype.ignoreFlash = false;\n    AS3Class.prototype.registerImports = function(clsList) {\n      var i;\n      for (i in this.imports) {\n        if (clsList[this.imports[i]]) {\n          var lastIndex = this.imports[i].lastIndexOf(\".\");\n          var shorthand = (lastIndex < 0) ? this.imports[i] : this.imports[i].substr(lastIndex + 1);\n          this.classMap[shorthand] = clsList[this.imports[i]];\n        }\n      }\n      for (i in this.importExtras) {\n        if (clsList[this.importExtras[i]]) {\n          var lastIndex = this.importExtras[i].lastIndexOf(\".\");\n          var shorthand = (lastIndex < 0) ? this.importExtras[i] : this.importExtras[i].substr(lastIndex + 1);\n          this.classMap[shorthand] = clsList[this.importExtras[i]];\n        }\n      }\n      this.packageMap = clsList;\n    };\n    AS3Class.prototype.registerField = function(name, value) {\n      if (value && value.isStatic) {\n        this.staticFieldMap[name] = this.staticFieldMap[name] || value;\n      } else {\n        this.fieldMap[name] = this.fieldMap[name] || value;\n      }\n    };\n    AS3Class.prototype.retrieveField = function(name, isStatic) {\n      if (isStatic) {\n        if (this.staticFieldMap[name]) {\n          return this.staticFieldMap[name];\n        } else if (this.parentDefinition) {\n          return this.parentDefinition.retrieveField(name, isStatic);\n        } else {\n          return null;\n        }\n      } else {\n        if (this.fieldMap[name]) {\n          return this.fieldMap[name];\n        } else if (this.parentDefinition) {\n          return this.parentDefinition.retrieveField(name, isStatic);\n        } else {\n          return null;\n        }\n      }\n    };\n    AS3Class.prototype.needsImport = function(pkg) {\n      var i;\n      var j;\n      var lastIndex = pkg.lastIndexOf(\".\");\n      var shorthand = (lastIndex < 0) ? pkg : pkg.substr(lastIndex + 1);\n      var matches;\n\n      if (this.imports.indexOf(pkg) >= 0) {\n        return false; //Class was already imported\n      }\n\n      if (shorthand == this.className && pkg == this.packageName) {\n        return true; //Don't need self\n      }\n\n      if (shorthand == this.parent) {\n        return true; //Parent class is in another package\n      }\n\n      //Now we must parse through all members one by one, looking at functions and variable types to determine the necessary imports\n\n      for (i in this.members) {\n        //See if the function definition or variable assigment have a need for this package\n        if (this.members[i] instanceof AS3Function) {\n          matches = this.members[i].value.match(AS3Pattern.VARIABLE_DECLARATION[1]);\n          for (j in matches) {\n            if (matches[j].split(\":\")[1] == shorthand)\n              return true;\n          }\n          for (j in this.members[i].argList) {\n            if (typeof this.members[i].argList[j].type == 'string' && this.members[i].argList[j].type == shorthand)\n              return true;\n          }\n        }\n        if (typeof this.members[i].value == 'string' && this.members[i].value.match(new RegExp(\"([^a-zA-Z_$.])\" + shorthand + \"([^0-9a-zA-Z_$])\", \"g\"))) {\n          return true;\n        } else if (typeof this.members[i].type == 'string' && this.members[i].type == shorthand) {\n          return true;\n        }\n      }\n      for (i in this.staticMembers) {\n        //See if the function definition or variable assigment have a need for this package\n        if (this.staticMembers[i] instanceof AS3Function) {\n          matches = this.staticMembers[i].value.match(AS3Pattern.VARIABLE_DECLARATION[1]);\n          for (j in matches) {\n            if (matches[j].split(\":\")[1] == shorthand) {\n              return true;\n            }\n          }\n          for (j in this.staticMembers[i].argList) {\n            if (typeof this.staticMembers[i].argList[j].type == 'string' && this.staticMembers[i].argList[j].type == shorthand) {\n              return true;\n            }\n          }\n        }\n        if (typeof this.staticMembers[i].value == 'string' && this.staticMembers[i].value.match(new RegExp(\"([^a-zA-Z_$.])\" + shorthand + \"([^0-9a-zA-Z_$])\", \"g\"))) {\n          return true;\n        } else if (typeof this.staticMembers[i].type == 'string' && this.staticMembers[i].type == shorthand) {\n          return true;\n        }\n      }\n      for (i in this.getters) {\n        //See if the function definition or variable assigment have a need for this package\n        matches = this.getters[i].value.match(AS3Pattern.VARIABLE_DECLARATION[1]);\n        for (j in matches) {\n          if (matches[j].split(\":\")[1] == shorthand) {\n            return true;\n          }\n        }\n        for (j in this.getters[i].argList) {\n          if (typeof this.getters[i].argList[j].type == 'string' && this.getters[i].argList[j].type == shorthand) {\n            return true;\n          }\n        }\n        if (typeof this.getters[i].value == 'string' && this.getters[i].value.match(new RegExp(\"([^a-zA-Z_$.])\" + shorthand + \"([^0-9a-zA-Z_$])\", \"g\"))) {\n          return true;\n        } else if (typeof this.getters[i].type == 'string' && this.getters[i].type == shorthand) {\n          return true;\n        }\n      }\n      for (i in this.setters) {\n        matches = this.setters[i].value.match(AS3Pattern.VARIABLE_DECLARATION[1]);\n        for (j in matches) {\n          if (matches[j].split(\":\")[1] == shorthand) {\n            return true;\n          }\n        }\n        //See if the function definition or variable assigment have a need for this package\n        for (j in this.setters[i].argList) {\n          if (typeof this.setters[i].argList[j].type == 'string' && this.setters[i].argList[j].type == shorthand) {\n            return true;\n          }\n        }\n        if (typeof this.setters[i].value == 'string' && this.setters[i].value.match(new RegExp(\"([^a-zA-Z_$.])\" + shorthand + \"([^0-9a-zA-Z_$])\", \"g\"))) {\n          return true;\n        } else if (typeof this.setters[i].type == 'string' && this.setters[i].type == shorthand) {\n          return true;\n        }\n      }\n      for (i in this.staticGetters) {\n        matches = this.staticGetters[i].value.match(AS3Pattern.VARIABLE_DECLARATION[1]);\n        for (j in matches) {\n          if (matches[j].split(\":\")[1] == shorthand) {\n            return true;\n          }\n        }\n        //See if the function definition or variable assigment have a need for this package\n        for (j in this.staticGetters[i].argList) {\n          if (typeof this.staticGetters[i].argList[j].type == 'string' && this.staticGetters[i].argList[j].type == shorthand) {\n            return true;\n          }\n        }\n        if (typeof this.staticGetters[i].value == 'string' && this.staticGetters[i].value.match(new RegExp(\"([^a-zA-Z_$.])\" + shorthand + \"([^0-9a-zA-Z_$])\", \"g\"))) {\n          return true;\n        } else if (typeof this.staticGetters[i].type == 'string' && this.staticGetters[i].type == shorthand) {\n          return true;\n        }\n      }\n      for (i in this.staticSetters) {\n        matches = this.staticSetters[i].value.match(AS3Pattern.VARIABLE_DECLARATION[1]);\n        for (j in matches) {\n          if (matches[j].split(\":\")[1] == shorthand) {\n            return true;\n          }\n        }\n        for (j in this.staticSetters[i].argList) {\n          if (typeof this.staticSetters[i].argList[j].type == 'string' && this.staticSetters[i].argList[j].type == shorthand) {\n            return true;\n          }\n        }\n        //See if the function definition or variable assigment have a need for this package\n        if (typeof this.staticSetters[i].value == 'string' && this.staticSetters[i].value.match(new RegExp(\"([^a-zA-Z_$.])\" + shorthand + \"([^0-9a-zA-Z_$])\", \"g\"))) {\n          return true;\n        } else if (typeof this.staticSetters[i].type == 'string' && this.staticSetters[i].type == shorthand) {\n          return true;\n        }\n      }\n\n      var classMember;\n      // Same logic as checkMembersWithAssignments()\n      // For each member that has an assignment at the top-level scope\n      for (i = 0; i < this.membersWithAssignments.length; i++) {\n        classMember = this.membersWithAssignments[i];\n        // Make a dumb attempt to identify use of the class as assignments here\n        if (classMember.value && classMember.value.indexOf(shorthand) >= 0 && !(this.parentDefinition && this.parentDefinition.packageName + \".\" + this.parentDefinition.className === pkg)) {\n          return true;\n        }\n      }\n\n      return false;\n    };\n    AS3Class.prototype.addImport = function(pkg) {\n      if (this.imports.indexOf(pkg) < 0) {\n        this.imports.push(pkg);\n      }\n    };\n    AS3Class.prototype.addExtraImport = function(pkg) {\n      if (this.importExtras.indexOf(pkg) < 0) {\n        this.importExtras.push(pkg);\n      }\n    };\n    AS3Class.prototype.findParents = function(classes) {\n      if (!this.parent) {\n        return;\n      }\n      for (var i in classes) {\n        //Only gather vars from the parent\n        if (classes[i] != this && this.parent == classes[i].className) {\n          this.parentDefinition = classes[i]; //Found our parent\n          return;\n        }\n      }\n    };\n    AS3Class.prototype.checkMembersWithAssignments = function() {\n      var i;\n      var j;\n      var classMember;\n      // If the type of this param is a Class\n      for (i = 0; i < this.membersWithAssignments.length; i++) {\n        classMember = this.membersWithAssignments[i];\n        // Make a dumb attempt to identify use of the class as assignments here\n        for (j in this.imports) {\n          if (this.packageMap[this.imports[j]] && classMember.value.indexOf(this.packageMap[this.imports[j]].className) >= 0 && this.parentDefinition !== this.packageMap[this.imports[j]]) {\n            // If this is a token that matches a class from an import statement, store it in the filtered classMap\n            this.classMapFiltered[this.packageMap[this.imports[j]].className] = this.packageMap[this.imports[j]];\n          }\n        }\n      }\n    };\n    AS3Class.prototype.stringifyFunc = function(fn) {\n      var buffer = \"\";\n      if (fn instanceof AS3Function) {\n        //Functions need to be handled differently\n        //Prepend sub-type if it exists\n        if (fn.subType) {\n          buffer += fn.subType + '_';\n        }\n        //Print out the rest of the name and start the function definition\n        buffer += fn.name\n        buffer += \" = function(\";\n        //Concat all of the arguments together\n        tmpArr = [];\n        for (j = 0; j < fn.argList.length; j++) {\n          if (!fn.argList[j].isRestParam) {\n            tmpArr.push(fn.argList[j].name);\n          }\n        }\n        buffer += tmpArr.join(\", \") + \") \";\n        //Function definition is finally added\n        buffer += fn.value + \";\\n\";\n      } else if (fn instanceof AS3Variable) {\n        //Variables can be added immediately\n        buffer += fn.name;\n        buffer += \" = \" + fn.value + \";\\n\";\n      }\n      return buffer;\n    };\n    AS3Class.prototype.process = function(classes) {\n      var self = this;\n      var i;\n      var index;\n      var currParent = this;\n      var allMembers = [];\n      var allFuncs = [];\n      var allStaticMembers = [];\n      var allStaticFuncs = [];\n\n      while (currParent) {\n        //Parse members of this parent\n        for (i in currParent.setters) {\n          allMembers.push(currParent.setters[i]);\n        }\n        for (i in currParent.staticSetters) {\n          allStaticMembers.push(currParent.staticSetters[i]);\n        }\n        for (i in currParent.getters) {\n          allMembers.push(currParent.getters[i]);\n        }\n        for (i in currParent.staticGetters) {\n          allStaticMembers.push(currParent.staticGetters[i]);\n        }\n        for (i in currParent.members) {\n          allMembers.push(currParent.members[i]);\n        }\n        for (i in currParent.staticMembers) {\n          allStaticMembers.push(currParent.staticMembers[i]);\n        }\n\n        //Go to the next parent\n        currParent = currParent.parentDefinition;\n      }\n\n      //Add copies of the setters and getters to the \"all\" arrays (for convenience)\n      for (i in this.setters) {\n        if (this.setters[i] instanceof AS3Function) {\n          allFuncs.push(this.setters[i]);\n        }\n      }\n      for (i in this.staticSetters) {\n        if (this.staticSetters[i] instanceof AS3Function) {\n          allStaticFuncs.push(this.staticSetters[i]);\n        }\n      }\n      for (i in this.getters) {\n        if (this.getters[i] instanceof AS3Function) {\n          allFuncs.push(this.getters[i]);\n        }\n      }\n      for (i in this.staticGetters) {\n        if (this.staticGetters[i] instanceof AS3Function) {\n          allStaticFuncs.push(this.staticGetters[i]);\n        }\n      }\n      for (i in this.members) {\n        if (this.members[i] instanceof AS3Function) {\n          allFuncs.push(this.members[i]);\n        }\n        if (this.members[i] instanceof AS3Variable) {\n          // Fix any obvious assignments that rely on implicit static class name (only works for simple statements)\n          if (this.members[i].value && this.retrieveField(this.members[i].value.replace(/^([a-zA-Z_$][0-9a-zA-Z_$]*)(.*?)$/g, \"$1\"), true)) {\n            this.members[i].value = this.className + '.' + this.members[i].value;\n          }\n        }\n      }\n      for (i in this.staticMembers) {\n        if (this.staticMembers[i] instanceof AS3Function) {\n          allStaticFuncs.push(this.staticMembers[i]);\n        }\n        if (this.staticMembers[i] instanceof AS3Variable) {\n          // Fix any obvious assignments that rely on implicit static class name (only works for simple statements)\n          if (this.staticMembers[i].value && this.retrieveField(this.staticMembers[i].value.replace(/^([a-zA-Z_$][0-9a-zA-Z_$]*)(.*?)$/g, \"$1\"), true)) {\n            this.staticMembers[i].value = this.className + '.' + this.staticMembers[i].value;\n          }\n        }\n      }\n\n      // Insert $init function for instantiations\n      for (i in allFuncs) {\n        Main.debug(\"Now parsing function: \" + this.className + \":\" + allFuncs[i].name);\n        allFuncs[i].value = AS3Parser.parseFunc(this, allFuncs[i].value, allFuncs[i].buildLocalVariableStack(), allFuncs[i].isStatic)[0];\n        allFuncs[i].value = AS3Parser.checkArguments(allFuncs[i]);\n        if (allFuncs[i].name === \"$init\") {\n          //Inject instantiations here\n          allFuncs[i].value = AS3Parser.injectInstantiations(this, allFuncs[i]);\n        }\n        if (allFuncs[i].name === this.className) {\n          //Inject $init() into constructor\n          allFuncs[i].value = AS3Parser.injectInit(this, allFuncs[i]);\n        }\n        allFuncs[i].value = AS3Parser.cleanup(allFuncs[i].value);\n        //Fix supers\n        allFuncs[i].value = allFuncs[i].value.replace(/super\\.(.*?)\\(/g, this.parent + '.prototype.$1.call(this, ').replace(/\\.call\\(this,\\s*\\)/g, \".call(this)\");\n        allFuncs[i].value = allFuncs[i].value.replace(/super\\(/g, this.parent + '.call(this, ').replace(/\\.call\\(this,\\s*\\)/g, \".call(this)\");\n        allFuncs[i].value = allFuncs[i].value.replace(new RegExp(\"this[.]\" + this.parent, \"g\"), this.parent); //Fix extra 'this' on the parent\n      }\n\n      for (i in allStaticFuncs) {\n        Main.debug(\"Now parsing static function: \" + this.className + \":\" + allStaticFuncs[i].name);\n        allStaticFuncs[i].value = AS3Parser.parseFunc(this, allStaticFuncs[i].value, allStaticFuncs[i].buildLocalVariableStack(), allStaticFuncs[i].isStatic)[0];\n        allStaticFuncs[i].value = AS3Parser.checkArguments(allStaticFuncs[i]);\n        allStaticFuncs[i].value = AS3Parser.cleanup(allStaticFuncs[i].value);\n      }\n    };\n    AS3Class.prototype.toString = function() {\n      //Outputs the class inside a JS function\n      var i;\n      var j;\n      var buffer = \"\";\n\n      if (this.requires.length > 0) {\n        if (this.safeRequire) {\n          for (i in this.requires) {\n            buffer += 'var ' + this.requires[i].substring(1, this.requires[i].length - 1) + ' = (function () { try { return require(' + this.requires[i] + '); } catch(e) { return undefined; }})();\\n';\n          }\n        } else {\n          for (i in this.requires) {\n            buffer += 'var ' + this.requires[i].substring(1, this.requires[i].length - 1) + ' = require(' + this.requires[i] + ');\\n';\n          }\n        }\n        buffer += \"\\n\";\n      }\n\n      var tmpArr = null;\n\n      //Parent class must be imported if it exists\n      if (this.parentDefinition) {\n        buffer += \"var \" + this.parentDefinition.className + \" = module.import('\" + this.parentDefinition.packageName + \"', '\" + this.parentDefinition.className + \"');\\n\";\n      }\n\n      //Create refs for all the other classes\n      if (this.imports.length > 0) {\n        tmpArr = [];\n        for (i in this.imports) {\n          if (!(this.ignoreFlash && this.imports[i].indexOf('flash.') >= 0) && this.parent != this.imports[i].substr(this.imports[i].lastIndexOf('.') + 1) && this.packageName + '.' + this.className != this.imports[i]) //Ignore flash imports\n          {\n            // Must be in the filtered map, otherwise no point in writing\n            if (!this.packageMap[this.imports[i]]) {\n              Main.warn(\"Warning, missing class path: \" + this.imports[i] + \" (found in \" + this.packageName + '.' + this.className + \")\");\n            } else if (this.classMapFiltered[this.packageMap[this.imports[i]].className]) {\n              tmpArr.push(this.imports[i].substr(this.imports[i].lastIndexOf('.') + 1)); //<-This will return characters after the final '.', or the entire String if no '.'\n            }\n          }\n        }\n        //Join up separated by commas\n        if (tmpArr.length > 0) {\n          buffer += 'var ';\n          buffer += tmpArr.join(\", \") + \";\\n\";\n        }\n      }\n      //Check for injection function code\n      var injectedText = \"\";\n      for (i in this.imports) {\n        if (!(this.ignoreFlash && this.imports[i].indexOf('flash.') >= 0) && this.packageName + '.' + this.className != this.imports[i] && !(this.parentDefinition && this.parentDefinition.packageName + '.' + this.parentDefinition.className == this.imports[i])) //Ignore flash imports and parent for injections\n        {\n          // Must be in the filtered map, otherwise no point in writing\n          if (!this.packageMap[this.imports[i]]) {\n            Main.warn(\"Warning, missing class path: \" + this.imports[i] + \" (found in \" + this.packageName + '.' + this.className + \")\");\n          } else if (this.classMapFiltered[this.packageMap[this.imports[i]].className]) {\n            injectedText += \"\\t\" + this.imports[i].substr(this.imports[i].lastIndexOf('.') + 1) + \" = module.import('\" + this.packageMap[this.imports[i]].packageName + \"', '\" + this.packageMap[this.imports[i]].className + \"');\\n\";\n          }\n        }\n      }\n\n      if (injectedText.length > 0) {\n        buffer += \"module.inject = function () {\\n\";\n        buffer += injectedText;\n        buffer += \"};\\n\";\n      }\n\n      buffer += '\\n';\n\n      buffer += (this.fieldMap[this.className]) ? \"var \" + this.stringifyFunc(this.fieldMap[this.className]) : \"var \" + this.className + \" = function \" + this.className + \"() {};\";\n\n      buffer += '\\n';\n      buffer += '\\n';\n\n      if (this.parent) {\n        //Extend parent if necessary\n        buffer += this.className + \".prototype = Object.create(\" + this.parent + \".prototype);\";\n      }\n\n      buffer += '\\n\\n';\n\n      // Deal with static member assigments\n      if (this.staticMembers.length > 0) {\n        //Place defaults first\n        for (i in this.staticMembers) {\n          if (this.staticMembers[i] instanceof AS3Function) {\n            buffer += this.className + \".\" + this.stringifyFunc(this.staticMembers[i]);\n          } else if (this.staticMembers[i].type === \"Number\" || this.staticMembers[i].type === \"int\" || this.staticMembers[i].type === \"uint\") {\n            if (isNaN(parseInt(this.staticMembers[i].value))) {\n              buffer += this.className + \".\" + this.staticMembers[i].name + ' = 0;\\n';\n            } else {\n              buffer += this.className + \".\" + this.stringifyFunc(this.staticMembers[i]);\n            }\n          } else if (this.staticMembers[i].type === \"Boolean\") {\n            buffer += this.className + \".\" + this.staticMembers[i].name + ' = false;\\n';\n          } else {\n            buffer += this.className + \".\" + this.staticMembers[i].name + ' = null;\\n';\n          }\n        }\n        for (i in this.staticGetters) {\n          buffer += this.className + \".\" + this.stringifyFunc(this.staticGetters[i]);\n        }\n        for (i in this.staticSetters) {\n          buffer += this.className + \".\" + this.stringifyFunc(this.staticSetters[i]);\n        }\n\n        buffer += '\\n';\n\n        buffer += this.className + \".$cinit = function () {\\n\";\n\n        // Now do the assignments for the rest\n        for (i in this.staticMembers) {\n          if (!(this.staticMembers[i] instanceof AS3Function)) {\n            buffer += \"\\t\" + AS3Parser.cleanup(this.className + '.' + this.staticMembers[i].name + ' = ' + this.staticMembers[i].value + \";\\n\");\n          }\n        }\n\n        buffer += '\\n';\n        buffer += \"};\\n\";\n      }\n      buffer += \"\\n\";\n\n      for (i in this.getters) {\n        buffer += this.className + \".prototype.\" + this.stringifyFunc(this.getters[i]);\n      }\n      for (i in this.setters) {\n        buffer += this.className + \".prototype.\" + this.stringifyFunc(this.setters[i]);\n      }\n      for (i in this.members) {\n        if (this.members[i].name === this.className) {\n          continue;\n        }\n        if (this.members[i] instanceof AS3Function || (AS3Class.nativeTypes.indexOf(this.members[i].type) >= 0 && this.members[i].value)) {\n          buffer += this.className + \".prototype.\" + this.stringifyFunc(this.members[i]); //Print functions immediately\n        } else if (this.members[i].type === \"Number\" || this.members[i].type === \"int\" || this.members[i].type === \"uint\") {\n          if (isNaN(parseInt(this.members[i].value))) {\n            buffer += this.className + \".prototype.\" + this.members[i].name + ' = 0;\\n';\n          } else {\n            buffer += this.className + \".prototype.\" + this.stringifyFunc(this.members[i]);\n          }\n        } else if (this.members[i].type === \"Boolean\") {\n          buffer += this.className + \".prototype.\" + this.members[i].name + ' = false;\\n';\n        } else {\n          buffer += this.className + \".prototype.\" + this.members[i].name + ' = null;\\n';\n        }\n      }\n\n      buffer = buffer.substr(0, buffer.length - 2) + \"\\n\"; //Strips the final comma out of the string\n\n      buffer += \"\\n\\n\";\n      buffer += \"module.exports = \" + this.className + \";\\n\";\n\n      //Remaining fixes\n      buffer = buffer.replace(/(this\\.)+/g, \"this.\");\n\n      return buffer;\n    }\n\n    module.exports = AS3Class;\n  };\n  Program[\"com.mcleodgaming.as3js.parser.AS3Parser\"] = function(module, exports) {\n    var path = (function() {\n      try {\n        return require(\"path\");\n      } catch (e) {\n        return undefined;\n      }\n    })();\n    var fs = (function() {\n      try {\n        return require(\"fs\");\n      } catch (e) {\n        return undefined;\n      }\n    })();\n\n    var Main, AS3Class, AS3Token, AS3Encapsulation, AS3MemberType, AS3ParseState, AS3Pattern, AS3Argument, AS3Function, AS3Member, AS3Variable;\n    module.inject = function() {\n      Main = module.import('com.mcleodgaming.as3js', 'Main');\n      AS3Class = module.import('com.mcleodgaming.as3js.parser', 'AS3Class');\n      AS3Token = module.import('com.mcleodgaming.as3js.parser', 'AS3Token');\n      AS3Encapsulation = module.import('com.mcleodgaming.as3js.enums', 'AS3Encapsulation');\n      AS3MemberType = module.import('com.mcleodgaming.as3js.enums', 'AS3MemberType');\n      AS3ParseState = module.import('com.mcleodgaming.as3js.enums', 'AS3ParseState');\n      AS3Pattern = module.import('com.mcleodgaming.as3js.enums', 'AS3Pattern');\n      AS3Argument = module.import('com.mcleodgaming.as3js.types', 'AS3Argument');\n      AS3Function = module.import('com.mcleodgaming.as3js.types', 'AS3Function');\n      AS3Member = module.import('com.mcleodgaming.as3js.types', 'AS3Member');\n      AS3Variable = module.import('com.mcleodgaming.as3js.types', 'AS3Variable');\n    };\n\n    var AS3Parser = function(src, classPath) {\n      this.$init();\n      classPath = AS3JS.Utils.getDefaultValue(classPath, null);\n      //index = 0;\n      this.stack = [];\n      this.src = src;\n      this.classPath = classPath;\n      this.parserOptions = {};\n      this.parserOptions.safeRequire = false;\n      this.parserOptions.ignoreFlash = false;\n    };\n\n    AS3Parser.PREVIOUS_BLOCK = null;\n    AS3Parser.increaseIndent = function(str, indent) {\n      return (indent + str).replace(/\\n/g, \"\\n\" + indent);\n    };\n    AS3Parser.parseArguments = function(str) {\n      var args = [];\n      var tmpToken;\n      var tmpArr = AS3Parser.extractBlock(str, 0, '(', ')');\n      var tmpExtractArr = null;\n      var index = tmpArr[1] - 1; //Ending index of parsed block\n      var tmpStr = tmpArr[0].trim(); //Parsed block\n      tmpStr = tmpStr.substr(1, tmpStr.length - 2); //Remove outer parentheses\n      tmpArr = null; //Trash this\n      tmpArr = tmpStr.split(','); //Split args by commas\n      //Don't bother if there are no arguments\n      if (tmpArr.length > 0 && tmpArr[0] != '') {\n        //Truncate spaces and assign values to arguments as needed\n        for (var i = 0; i < tmpArr.length; i++) {\n          tmpStr = tmpArr[i].trim();\n          args.push(new AS3Argument());\n          if (tmpStr.indexOf('...') === 0) {\n            //This is a ...rest argument, stop here\n            args[args.length - 1].name = tmpStr.substr(3);\n            args[args.length - 1].isRestParam = true;\n            Main.debug('----->Parsed a ...rest param: ' + args[args.length - 1].name);\n            break;\n          } else {\n            //Grab the function name\n            tmpToken = AS3Parser.nextWord(tmpStr, 0, AS3Pattern.VARIABLE[0], AS3Pattern.VARIABLE[1]); //Parse out the function name\n            args[args.length - 1].name = tmpToken.token; //Set the argument name\n            Main.debug('----->Sub-Function argument found: ' + tmpToken.token);\n            //If a colon was next, we'll assume it was typed and grab it\n            if (tmpToken.index < tmpStr.length && tmpStr.charAt(tmpToken.index) == ':') {\n              tmpToken = AS3Parser.nextWord(tmpStr, tmpToken.index, AS3Pattern.VARIABLE_TYPE[0], AS3Pattern.VARIABLE_TYPE[1]); //Parse out the argument type\n              args[args.length - 1].type = tmpToken.token; //Set the argument type\n              Main.debug('----->Sub-Function argument typed to: ' + tmpToken.token);\n            }\n            tmpToken = AS3Parser.nextWord(tmpStr, tmpToken.index, AS3Pattern.ASSIGN_START[0], AS3Pattern.ASSIGN_START[1]);\n            if (tmpToken.token == \"=\") {\n              //Use all characters after self symbol to set value\n              tmpExtractArr = AS3Parser.extractUpTo(tmpStr, tmpToken.index, /[;\\r\\n]/g);\n              //Store value\n              args[args.length - 1].value = tmpExtractArr[0].trim();\n              //Store value\n              Main.debug('----->Sub-Function argument defaulted to: ' + tmpExtractArr[0].trim());\n            }\n          }\n        }\n      }\n      return args;\n    };\n    AS3Parser.checkForCommentOpen = function(str) {\n      return (str == \"//\") ? AS3ParseState.COMMENT_INLINE : (str == \"/*\") ? AS3ParseState.COMMENT_MULTILINE : null;\n    };\n    AS3Parser.checkForCommentClose = function(state, str) {\n      return (state == AS3ParseState.COMMENT_INLINE && (str.charAt(0) == '\\n' || str.charAt(0) == '\\r' || str.charAt(0) == '')) ? true : (state == AS3ParseState.COMMENT_MULTILINE && str == \"*/\") ? true : false;\n    };\n    AS3Parser.checkForStringOpen = function(str) {\n      return (str == '\"') ? AS3ParseState.STRING_DOUBLE_QUOTE : (str == \"'\") ? AS3ParseState.STRING_SINGLE_QUOTE : null;\n    };\n    AS3Parser.checkForStringClose = function(state, str) {\n      return (state == AS3ParseState.STRING_DOUBLE_QUOTE && str == '\"') ? true : (state == AS3ParseState.STRING_SINGLE_QUOTE && str == \"'\") ? true : false;\n    };\n    AS3Parser.nextWord = function(src, index, characters, pattern) {\n      characters = characters || AS3Pattern.IDENTIFIER[0];\n      pattern = pattern || AS3Pattern.IDENTIFIER[1];\n      var tokenBuffer = null;\n      var extraBuffer = ''; //Contains characters that were missed\n      var escapeToggle = false;\n      var innerState = null;\n      for (; index < src.length; index++) {\n        var c = src.charAt(index);\n        if (c.match(characters)) {\n          tokenBuffer = (tokenBuffer) ? tokenBuffer + c : c; //Create new token buffer if needed, otherwise append\n        } else if (!innerState && AS3Parser.checkForCommentOpen(src.substr(index, 2)) && !tokenBuffer) {\n          tokenBuffer = null;\n          Main.debug(\"Entering comment...\");\n          innerState = AS3Parser.checkForCommentOpen(src.substr(index, 2));\n          extraBuffer += src.substr(index, 2);\n          index += 2; //Skip next index\n          //Loop until we break out of comment\n          for (; index < src.length; index++) {\n            if (AS3Parser.checkForCommentClose(innerState, src.substr(index, 2))) {\n              if (innerState == AS3ParseState.COMMENT_MULTILINE) {\n                extraBuffer += src.substr(index, 2);\n                index++; //Skip next token\n              } else {\n                extraBuffer += src.charAt(index);\n              }\n              innerState = null; //Return to previous state\n              Main.debug(\"Exiting comment...\");\n              break;\n            } else {\n              extraBuffer += src.charAt(index);\n            }\n          }\n        } else if (!innerState && AS3Parser.checkForStringOpen(src.charAt(index)) && !tokenBuffer) {\n          tokenBuffer = null;\n          Main.debug(\"Entering string...\");\n          innerState = AS3Parser.checkForStringOpen(src.charAt(index));\n          extraBuffer += src.substr(index, 1);\n          index++; //Skip to next index\n          //Loop until we break out of string\n          for (; index < src.length; index++) {\n            extraBuffer += src.charAt(index);\n            if (!escapeToggle && src.charAt(index) == '\\\\') {\n              escapeToggle = true;\n              continue;\n            }\n            escapeToggle = false;\n            if (AS3Parser.checkForStringClose(innerState, src.charAt(index))) {\n              innerState = null; //Return to previous state\n              Main.debug(\"Exiting string...\");\n              break;\n            }\n          }\n        } else if (tokenBuffer && tokenBuffer.match(pattern)) {\n          return new AS3Token(tokenBuffer, index, extraBuffer); //[Token, Index]\n        } else {\n          if (tokenBuffer) {\n            extraBuffer += tokenBuffer + c;\n          } else {\n            extraBuffer += c;\n          }\n          tokenBuffer = null;\n        }\n      }\n      return new AS3Token(tokenBuffer || null, index, extraBuffer); //[Token, Index]\n    };\n    AS3Parser.extractBlock = function(text, start, opening, closing) {\n      start = AS3JS.Utils.getDefaultValue(start, 0);\n      opening = AS3JS.Utils.getDefaultValue(opening, \"{\");\n      closing = AS3JS.Utils.getDefaultValue(closing, \"}\");\n      var buffer = \"\";\n      var i = start;\n      var count = 0;\n      var started = false;\n      var insideString = null;\n      var insideComment = null;\n      var escapingChar = false;\n      while (!(count == 0 && started) && i < text.length) {\n        if (insideComment) {\n          //Inside of a comment, wait until we get out\n          if (insideComment == '//' && (text.charAt(i) == '\\n' || text.charAt(i) == '\\r')) {\n            insideComment = null; //End inline comment\n            Main.debug(\"Exited comment\");\n          } else if (insideComment == '/*' && text.charAt(i) == '*' && i + 1 < text.length && text.charAt(i + 1) == '/') {\n            insideComment = null; //End multiline comment\n            Main.debug(\"Exited comment\");\n          }\n        } else if (insideString) {\n          //Inside of a string, wait until we get out\n          if (!escapingChar && text.charAt(i) == \"\\\\\") {\n            escapingChar = true; //Start escape sequence\n          } else if (!escapingChar && text.charAt(i) == insideString) {\n            insideString = null; //Found closing quote\n          } else {\n            escapingChar = false; //Forget escape sequence\n          }\n        } else if (text.charAt(i) == opening) {\n          started = true;\n          count++; //Found opening\n        } else if (text.charAt(i) == closing) {\n          count--; //Found closing\n        } else if ((text.charAt(i) == '\\\"' || text.charAt(i) == '\\'')) {\n          insideString = text.charAt(i); //Now inside of a string\n        } else if (text.charAt(i) == '/' && i + 1 < text.length && text.charAt(i + 1) == '/') {\n          Main.debug(\"Entering comment... \" + \"(//)\");\n          insideComment = '//';\n        } else if (text.charAt(i) == '/' && i + 1 < text.length && text.charAt(i + 1) == '*') {\n          Main.debug(\"Entering comment...\" + \"(/*)\");\n          insideComment = '/*';\n        }\n        if (started) {\n          buffer += text.charAt(i);\n        }\n        i++;\n      }\n      if (!started) {\n        throw new Error(\"Error, no starting '\" + opening + \"' found for method body while parsing \" + AS3Parser.PREVIOUS_BLOCK);\n      } else if (count > 0) {\n        throw new Error(\"Error, no closing '\" + closing + \"' found for method body while parsing \" + AS3Parser.PREVIOUS_BLOCK);\n      } else if (count < 0) {\n        throw new Error(\"Error, malformed enclosing '\" + opening + closing + \" body while parsing \" + AS3Parser.PREVIOUS_BLOCK);\n      }\n      return [buffer, i];\n    };\n    AS3Parser.extractUpTo = function(text, start, target) {\n      var buffer = \"\";\n      var i = start;\n      var insideString = null;\n      var insideComment = null;\n      var escapingChar = false;\n      var pattern = new RegExp(target);\n      while (i < text.length) {\n        if (insideComment) {\n          //Inside of a comment, wait until we get out\n          if (insideComment == '//' && (text.charAt(i) == '\\n' || text.charAt(i) == '\\r')) {\n            insideComment = null; //End inline comment\n            Main.debug(\"Exited comment\");\n          } else if (insideComment == '/*' && text.charAt(i) == '*' && i + 1 < text.length && text.charAt(i + 1) == '/') {\n            insideComment = null; //End multiline comment\n            Main.debug(\"Exited comment\");\n          }\n        } else if (insideString) {\n          //Inside of a string, wait until we get out\n          if (!escapingChar && text.charAt(i) == \"\\\\\") {\n            escapingChar = true; //Start escape sequence\n          } else if (!escapingChar && text.charAt(i) == insideString) {\n            insideString = null; //Found closing quote\n          } else {\n            escapingChar = false; //Forget escape sequence\n          }\n        } else if ((text.charAt(i) == '\\\"' || text.charAt(i) == '\\'')) {\n          insideString = text.charAt(i); //Now inside of a string\n        } else if (text.charAt(i) == '/' && i + 1 < text.length && text.charAt(i + 1) == '/') {\n          Main.debug(\"Entering comment... \" + \"(//)\");\n          insideComment = '//';\n        } else if (text.charAt(i) == '/' && i + 1 < text.length && text.charAt(i + 1) == '*') {\n          Main.debug(\"Entering comment...\" + \"(/*)\");\n          insideComment = '/*';\n        } else if (text.charAt(i).match(pattern)) {\n          break; //Done\n        }\n        buffer += text.charAt(i);\n        i++;\n      }\n      return [buffer, i];\n    };\n    AS3Parser.fixClassPath = function(clsPath) {\n      // Class paths at the root level might accidentally be prepended with a \".\"\n      return clsPath.replace(/^\\./g, \"\");\n    };\n    AS3Parser.checkArguments = function(fn) {\n      if (fn.argList.length <= 0) {\n        return fn.value;\n      }\n      var start = fn.value.indexOf('{');\n      var args = \"\";\n      for (var i = 0; i < fn.argList.length; i++) {\n        //We will inject arguments into the top of the method definition\n        if (fn.argList[i].isRestParam) {\n          args += \"\\n\\t\\t\\tvar \" + fn.argList[i].name + \" = Array.prototype.slice.call(arguments).splice(\" + i + \");\";\n        } else if (fn.argList[i].value) {\n          args += \"\\n\\t\\t\\t\" + fn.argList[i].name + \" = AS3JS.Utils.getDefaultValue(\" + fn.argList[i].name + \", \" + fn.argList[i].value + \");\";\n        }\n      }\n      return fn.value.substr(0, start + 1) + args + fn.value.substr(start + 1);\n    };\n    AS3Parser.injectInstantiations = function(cls, fn) {\n      var start = fn.value.indexOf('{');\n      var text = \"\";\n      for (var i = 0; i < cls.members.length; i++) {\n        //We will inject instantiated vars into the top of the method definition\n        if (cls.members[i] instanceof AS3Variable && AS3Class.nativeTypes.indexOf(cls.members[i].type) < 0) {\n          text += \"\\n\\t\\t\\tthis.\" + cls.members[i].name + \" = \" + cls.members[i].value + \";\";\n        }\n      }\n      return fn.value.substr(0, start + 1) + text + fn.value.substr(start + 1);\n    };\n    AS3Parser.injectInit = function(cls, fn) {\n      var start = fn.value.indexOf('{');\n      var text = \"\\n\\t\\t\\tthis.$init();\";\n\n      return fn.value.substr(0, start + 1) + text + fn.value.substr(start + 1);\n    };\n    AS3Parser.checkStack = function(stack, name) {\n      if (!name) {\n        return null;\n      }\n      for (var i = stack.length - 1; i >= 0; i--) {\n        if (stack[i].name == name) {\n          return stack[i];\n        }\n      }\n      return null;\n    };\n    AS3Parser.lookAhead = function(str, index) {\n      //Look ahead in the function for assignments\n      var originalIndex = index;\n      var startIndex = -1;\n      var endIndex = -1;\n      var semicolonIndex = -1;\n      var token = \"\";\n      var extracted = \"\";\n      //Not a setter if there is a dot operator immediately after\n      if (str.charAt(index) == '.') {\n        return {\n          token: null,\n          extracted: '',\n          startIndex: startIndex,\n          endIndex: endIndex\n        };\n      }\n      for (; index < str.length; index++) {\n        if (str.charAt(index).match(/[+-\\/=*]/g)) {\n          //Append to the assignment instruction\n          token += str.charAt(index);\n          startIndex = index;\n        } else if (startIndex < 0 && str.charAt(index).match(/[\\t\\s]/g)) //Skip these characters\n        {\n          continue;\n        } else {\n          break; //Exits when token has already been started and no more regexes pass\n        }\n      }\n\n      //Only allow these patterns\n      if (!(token == \"=\" || token == \"++\" || token == \"--\" || token == \"+=\" || token == \"-=\" || token == \"*=\" || token == \"/=\")) {\n        token = null;\n      }\n\n      if (token) {\n        //Pick whatever is closer, new line or semicolon\n        endIndex = str.indexOf('\\n', startIndex);\n        if (endIndex < 0) {\n          endIndex = str.length - 1;\n        }\n        //Windows fix\n        if (str.charAt(endIndex - 1) == '\\r') {\n          endIndex--;\n        }\n        //We want to place closing parens before semicolon if it exists\n        semicolonIndex = str.indexOf(\";\", startIndex);\n        if (semicolonIndex < endIndex) {\n          endIndex = semicolonIndex;\n        }\n        extracted = str.substring(startIndex + token.length, endIndex);\n      }\n\n      return {\n        token: token,\n        extracted: extracted,\n        startIndex: startIndex,\n        endIndex: endIndex\n      };\n    };\n    AS3Parser.parseFunc = function(cls, fnText, stack, statFlag) {\n      statFlag = AS3JS.Utils.getDefaultValue(statFlag, false);\n      var i;\n      var j;\n      var index = 0;\n      var result = '';\n      var tmpStr = '';\n      var tmpArgs;\n      var tmpMember;\n      var tmpClass;\n      var tmpField;\n      var prevToken;\n      var currToken;\n      var tmpParse;\n      var tmpStatic = false;\n      var tmpPeek;\n      var objBuffer = ''; //Tracks the current object that is being \"pathed\" (e.g. \"object.field1\" or \"object.field1[index + 1]\", etc)\n      var justCreatedVar = false; //Keeps track if we just started a var statement (to help test if we're setting a type))\n      for (index = 0; index < fnText.length; index++) {\n        objBuffer = '';\n        prevToken = currToken;\n        currToken = AS3Parser.nextWord(fnText, index, AS3Pattern.VARIABLE[0], AS3Pattern.VARIABLE[1]);\n        result += currToken.extra; //<-Puts all other non-identifier characters into the buffer first\n        tmpMember = AS3Parser.checkStack(stack, currToken.token); //<-Check the stack for a member with this identifier already\n        index = currToken.index;\n        if (currToken.token) {\n          if (currToken.token == 'function') {\n            var t1 = AS3Parser.nextWord(fnText, index, AS3Pattern.VARIABLE[0], AS3Pattern.VARIABLE[1]);\n            var t2 = fnText.indexOf('(', index);\n            //If the parenthesis si less than the last index of the next parsed variable name\n            result += (t2 < t1.index) ? 'function' : 'function ' + t1.token;\n            tmpParse = AS3Parser.extractBlock(fnText, index, '(', ')'); //Parse out argument block\n            index = tmpParse[1]; //Update index\n            tmpArgs = AS3Parser.parseArguments(tmpParse[0]); //Extract arg types\n            //Join the args together without types\n            result += '(' + (function(args) {\n              var arr = [];\n              for (var i = 0; i < args.length; i++) {\n                if (args[i] === '...rest') {\n                  break;\n                }\n                arr.push(args[i].name);\n              }\n              var str = arr.join(', ');\n              return str;\n            })(tmpArgs) + ')';\n            tmpParse = AS3Parser.extractBlock(fnText, index, '{', '}'); //Extract function block\n            index = tmpParse[1] - 1; //Update index\n            tmpParse = AS3Parser.parseFunc(cls, tmpParse[0], stack.concat(tmpArgs), statFlag); //Recurse into function\n            result += ' ' + tmpParse[0];\n          } else {\n            if (currToken.token == 'this') {\n              //No need to perform any extra checks on the subsequent token\n              tmpStatic = false;\n              tmpClass = cls;\n              objBuffer += currToken.token;\n              result += currToken.token;\n            } else {\n              if (cls.classMap[currToken.token] && cls.parentDefinition !== cls.classMap[currToken.token] && !(justCreatedVar && currToken.extra.match(/:\\s*/g))) {\n                // If this is a token that matches a class from a potential import statement, store it in the filtered classMap\n                cls.classMapFiltered[currToken.token] = cls.classMap[currToken.token];\n              }\n              tmpStatic = (cls.className == currToken.token || cls.retrieveField(currToken.token, true) !== null);\n\n              //Find field in class, then make sure we didn't already have a local member defined with this name, and skip next block if static since the definition is the class itself\n              //Note: tmpMember needs to be checked, if something is in there it means we have a variable with the same name in local scope\n              if (cls.retrieveField(currToken.token, tmpStatic) && cls.className != currToken.token && !tmpMember && !(prevToken && prevToken.token === \"var\")) {\n                tmpMember = cls.retrieveField(currToken.token, tmpStatic); //<-Reconciles the type of the current variable\n                if (tmpMember && (tmpMember.subType == 'get' || tmpMember.subType == 'set')) {\n                  tmpPeek = AS3Parser.lookAhead(fnText, index);\n                  if (tmpPeek.token) {\n                    //Handle differently if we are assigning a setter\n\n                    //Prepend the correct term\n                    if (tmpStatic) {\n                      objBuffer += (cls.retrieveField(currToken.token, tmpStatic)) ? cls.className + '.' : currToken.token + '.';\n                      result += (cls.retrieveField(currToken.token, tmpStatic)) ? cls.className + '.' : currToken.token + '.';\n                    } else {\n                      objBuffer += 'this.';\n                      result += 'this.';\n                    }\n                    objBuffer += 'get_' + currToken.token + '()';\n                    result += 'set_' + currToken.token + '(';\n                    index = tmpPeek.endIndex;\n                    if (tmpPeek.token == '++') {\n                      result += objBuffer + ' + 1';\n                    } else if (tmpPeek.token == '--') {\n                      result += objBuffer + ' - 1';\n                    } else {\n                      tmpParse = AS3Parser.parseFunc(cls, tmpPeek.extracted, stack); //Recurse into the assignment to parse vars\n                      if (tmpPeek.token == '=') {\n                        result += tmpParse[0].trim();\n                      } else {\n                        result += objBuffer + ' ' + tmpPeek.token.charAt(0) + ' (' + tmpParse[0] + ')';\n                      }\n                    }\n                    result += ')';\n                  } else {\n                    //Getters are easy\n                    if (tmpStatic) {\n                      objBuffer += (cls.retrieveField(currToken.token, true)) ? cls.className + '.get_' + currToken.token + '()' : 'this.get_' + currToken.token + '()';\n                      result += (cls.retrieveField(currToken.token, true)) ? cls.className + '.get_' + currToken.token + '()' : 'this.get_' + currToken.token + '()';\n                    } else {\n                      objBuffer += 'this.get_' + currToken.token + '()';\n                      result += 'this.get_' + currToken.token + '()';\n                    }\n                  }\n                } else {\n                  if (tmpStatic) {\n                    objBuffer += (cls.className == currToken.token) ? currToken.token : cls.className + '.' + currToken.token;\n                    result += (cls.className == currToken.token) ? currToken.token : cls.className + '.' + currToken.token;\n                  } else {\n                    objBuffer += (cls.retrieveField(currToken.token, false) && !statFlag && !(prevToken && prevToken.token === 'new' && cls.retrieveField(currToken.token, false).type !== \"Class\")) ? 'this.' + currToken.token : currToken.token;\n                    result += (cls.retrieveField(currToken.token, false) && !statFlag && !(prevToken && prevToken.token === 'new' && cls.retrieveField(currToken.token, false).type !== \"Class\")) ? 'this.' + currToken.token : currToken.token;\n                  }\n                }\n              } else {\n                //Likely a local variable, argument, or static reference\n                if (tmpStatic) {\n                  objBuffer += currToken.token;\n                  result += currToken.token;\n                } else {\n                  objBuffer += (cls.retrieveField(currToken.token, false) && !tmpMember && !(prevToken && prevToken.token === \"var\")) ? 'this.' + currToken.token : currToken.token;\n                  result += (cls.retrieveField(currToken.token, false) && !tmpMember && !(prevToken && prevToken.token === \"var\")) ? 'this.' + currToken.token : currToken.token;\n                }\n              }\n              if (tmpStatic) {\n                //Just use the class itself, we will reference fields from it. If parser injected the static prefix manually, we'll try to determome the type of var instead\n                tmpClass = (cls.className == currToken.token) ? cls : (tmpMember) ? cls.classMap[tmpMember.type] || null : null;\n              } else {\n                //Use the member's type to determine the class it's mapped to\n                tmpClass = (tmpMember && tmpMember.type && tmpMember.type != '*') ? cls.classMap[tmpMember.type] : null;\n                //If no mapping was found, this may be a static reference\n                if (!tmpClass && cls.classMap[currToken.token]) {\n                  tmpClass = cls.classMap[currToken.token];\n                  tmpStatic = true;\n                }\n              }\n              //If tmpClass is null, it's possible we were trying to retrieve a Vector type. Let's fix this:\n              if (!tmpClass && tmpMember && tmpMember.type && tmpMember.type.replace(/Vector\\.<(.*?)>/g, \"$1\") != tmpMember.type) {\n                //Extract Vector type if necessary by testing regex\n                tmpClass = cls.classMap[tmpMember.type.replace(/Vector\\.<(.*?)>/g, \"$1\")] || null;\n              }\n            }\n            //Note: At this point, tmpMember is no longer used, it was only needed to remember the type of the first token. objBuffer will be building out the token\n\n            //If this had a variable declaration before it, we will add it to the local var stack and move on to the next token\n            if (prevToken && prevToken.token === \"var\") {\n              justCreatedVar = true;\n              if (cls.retrieveField(currToken.token, tmpStatic)) {\n                //Appends current character index to the result, add dummy var to stack, and move on\n                result += fnText.charAt(index);\n                var localVar = new AS3Member();\n                localVar.name = currToken.token;\n                stack.push(localVar); //<-Ensures we don't add \"this.\" or anything in front of this variable anymore\n                continue;\n              }\n            } else {\n              justCreatedVar = false;\n            }\n\n            //We have parsed the current token, and the index sits at the next level down in the object\n            for (; index < fnText.length; index++) {\n              //Loop until we stop parsing a variable declaration\n              if (fnText.charAt(index) == '.') {\n                var parsingVector = (prevToken && prevToken.token === 'new' && currToken.token === 'Vector');\n                prevToken = currToken;\n                if (parsingVector) {\n                  //We need to allow asterix\n                  currToken = AS3Parser.nextWord(fnText, index, AS3Pattern.VARIABLE_TYPE[0], AS3Pattern.VARIABLE_TYPE[1]);\n                } else {\n                  currToken = AS3Parser.nextWord(fnText, index, AS3Pattern.VARIABLE[0], AS3Pattern.VARIABLE[1]);\n                }\n                result += currToken.extra; //<-Puts all other non-identifier characters into the buffer first\n                index = currToken.index;\n                if (tmpClass) {\n                  //This means we are coming from a typed variable\n                  tmpField = tmpClass.retrieveField(currToken.token, tmpStatic);\n                  if (tmpField) {\n                    //console.log(\"parsing: \" + tmpField.name + \":\" + tmpField.type)\n                    //We found a field that matched this value within the class\n                    if (tmpField instanceof AS3Function) {\n                      if (tmpField.subType == 'get' || tmpField.subType == 'set') {\n                        tmpPeek = AS3Parser.lookAhead(fnText, index);\n                        if (tmpPeek.token) {\n                          //Handle differently if we are assigning a setter\n                          objBuffer += '.get_' + currToken.token + '()';\n                          result += 'set_' + currToken.token + '(';\n                          index = tmpPeek.endIndex;\n                          if (tmpPeek.token == '++') {\n                            result += objBuffer + ' + 1';\n                          } else if (tmpPeek.token == '--') {\n                            result += objBuffer + ' - 1';\n                          } else {\n                            tmpParse = AS3Parser.parseFunc(cls, tmpPeek.extracted, stack); //Recurse into the assignment to parse vars\n                            if (tmpPeek.token == '=') {\n                              result += tmpParse[0].trim();\n                            } else {\n                              result += objBuffer + ' ' + tmpPeek.token.charAt(0) + ' (' + tmpParse[0] + ')';\n                            }\n                          }\n                          result += ')';\n                        } else {\n                          objBuffer += '.get_' + currToken.token + '()';\n                          result += 'get_' + currToken.token + \"()\";\n                        }\n                        //console.log(\"set get flag: \" + currToken.token);\n                      } else {\n                        objBuffer += '.' + currToken.token;\n                        result += currToken.token;\n                      }\n                    } else {\n                      objBuffer += '.' + currToken.token;\n                      result += currToken.token;\n                    }\n                  } else {\n                    objBuffer += '.' + currToken.token;\n                    result += currToken.token;\n                    //console.log(\"appened typed: \" + currToken.token);\n                  }\n                  //Update the type if this is not a static prop\n                  if (tmpClass && tmpField && tmpField.type && tmpField.type != '*') {\n                    //Extract Vector type if necessary by testing regex\n                    tmpClass = (tmpField.type.replace(/Vector\\.<(.*?)>/g, \"$1\") != tmpField.type) ? tmpClass.classMap[tmpField.type.replace(/Vector\\.<(.*?)>/g, \"$1\")] || null : tmpClass.classMap[tmpField.type] || null;\n                  } else {\n                    tmpClass = null;\n                  }\n                } else {\n                  //console.log(\"appened untyped: \" + currToken.token);\n                  objBuffer += '.' + currToken.token;\n                  result += currToken.token;\n                }\n              } else if (fnText.charAt(index) == '[') {\n                //We now have to recursively parse the inside of this open bracket\n                tmpParse = AS3Parser.extractBlock(fnText, index, '[', ']');\n                index = tmpParse[1];\n                tmpParse = AS3Parser.parseFunc(cls, tmpParse[0], stack); //Recurse into the portion that was extracted\n                //console.log(\"recursed into: \" + tmpParse[0]);\n                objBuffer += tmpParse[0]; //Append this text to the object buffer string so we can remember the variable we have accessed\n                result += tmpParse[0];\n              }\n              tmpStatic = false; //Static can no longer be possible after the second field\n              if (!fnText.charAt(index).match(/[.\\[]/g)) {\n                objBuffer = ''; //Clear out the current object buffer\n                index--;\n                break;\n              }\n              index--;\n            }\n          }\n        } else {\n          index = currToken.index - 1;\n        }\n      }\n      return [result, index];\n    };\n    AS3Parser.cleanup = function(text) {\n      var i;\n      var type;\n      var params;\n      var val;\n      var matches = text.match(AS3Pattern.VECTOR[0]);\n      //For each Vector.<>() found in the text\n      for (i in matches) {\n        //Strip the type and provided params\n        type = matches[i].replace(AS3Pattern.VECTOR[0], '$1').trim();\n        params = matches[i].replace(AS3Pattern.VECTOR[0], '$2').split(',');\n        //Set the default based on var type\n        if (type == 'int' || type == 'uint' || type == 'Number') {\n          val = \"0\";\n        } else if (type == 'Boolean') {\n          val = \"false\";\n        } else {\n          val = \"null\";\n        }\n        //Replace accordingly\n        if (params.length > 0 && params[0].trim() != '') {\n          text = text.replace(AS3Pattern.VECTOR[1], \"AS3JS.Utils.createArray(\" + params[0] + \", \" + val + \")\");\n        } else {\n          text = text.replace(AS3Pattern.VECTOR[1], \"[]\");\n        }\n      }\n      matches = text.match(AS3Pattern.ARRAY[0]);\n      //For each Array() found in the text\n      for (i in matches) {\n        //Strip the provided params\n        params = matches[i].replace(AS3Pattern.ARRAY[0], '$1').trim();\n        //Replace accordingly\n        if (params.length > 0 && params[0].trim() != '') {\n          text = text.replace(AS3Pattern.ARRAY[1], \"AS3JS.Utils.createArray(\" + params[0] + \", null)\");\n        } else {\n          text = text.replace(AS3Pattern.ARRAY[1], \"[]\");\n        }\n      }\n\n      matches = text.match(AS3Pattern.DICTIONARY[0]);\n      //For each instantiated Dictionary found in the text\n      for (i in matches) {\n        // Replace with empty object\n        text = text.replace(AS3Pattern.DICTIONARY[0], \"{}\");\n      }\n\n      //Now cleanup variable types\n      text = text.replace(/([^0-9a-zA-Z_$.])(?:var|const)(\\s*[a-zA-Z_$*][0-9a-zA-Z_$.<>]*)\\s*:\\s*([a-zA-Z_$*][0-9a-zA-Z_$.<>]*)/g, \"$1var$2\");\n\n      return text;\n    };\n\n    AS3Parser.$cinit = function() {\n      AS3Parser.PREVIOUS_BLOCK = null;\n\n    };\n\n    AS3Parser.prototype.$init = function() {\n      this.stack = null;\n      this.parserOptions = null;\n    };\n    AS3Parser.prototype.stack = null;\n    AS3Parser.prototype.src = null;\n    AS3Parser.prototype.classPath = null;\n    AS3Parser.prototype.parserOptions = null;\n    AS3Parser.prototype.getState = function() {\n      return (this.stack.length > 0) ? this.stack[this.stack.length - 1] : null;\n    };\n    AS3Parser.prototype.parseHelper = function(cls, src) {\n      var i;\n      var j;\n      var c;\n      var currToken = null;\n      var tmpToken = null;\n      var tmpStr = null;\n      var tmpArr = null;\n      var currMember = null;\n      var index;\n      for (index = 0; index < src.length; index++) {\n        c = src.charAt(index);\n        if (this.getState() == AS3ParseState.START) {\n          //String together letters only until we reach a non-letter\n          currToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]);\n          index = currToken.index - 1; //Update to the new position\n          if (currToken.token == 'package') {\n            this.stack.push(AS3ParseState.PACKAGE_NAME);\n          }\n        } else if (this.getState() == AS3ParseState.PACKAGE_NAME) {\n          currToken = AS3Parser.nextWord(src, index, AS3Pattern.OBJECT[0], AS3Pattern.OBJECT[1]); //Package name\n          tmpToken = AS3Parser.nextWord(src, index, AS3Pattern.CURLY_BRACE[0], AS3Pattern.CURLY_BRACE[1]); //Upcoming curly brace\n\n          index = currToken.index - 1;\n          if (!currToken.token || !tmpToken.token) {\n            throw new Error(\"Error parsing package name.\");\n          } else {\n            if (tmpToken.index < currToken.index) {\n              cls.packageName = ''; //Curly brace came before next token\n              index = tmpToken.index;\n            } else {\n              cls.packageName = currToken.token; //Just grab the package name\n            }\n            Main.debug('Found package: ' + cls.packageName);\n            cls.importWildcards.push(AS3Parser.fixClassPath(cls.packageName + '.*')); //Add wild card for its own folder\n            this.stack.push(AS3ParseState.PACKAGE);\n            Main.debug('Attempting to parse package...');\n          }\n        } else if (this.getState() == AS3ParseState.PACKAGE) {\n          currToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]);\n          index = currToken.index - 1;\n          if (currToken.token == 'class' || currToken.token == 'interface') {\n            if (currToken.token == 'interface')\n              cls.isInterface = true;\n            this.stack.push(AS3ParseState.CLASS_NAME);\n            Main.debug('Found class keyword...');\n          } else if (currToken.token == 'import') {\n            this.stack.push(AS3ParseState.IMPORT_PACKAGE);\n            Main.debug('Found import keyword...');\n          } else if (currToken.token == 'require') {\n            this.stack.push(AS3ParseState.REQUIRE_MODULE);\n            Main.debug('Found require keyword...');\n          }\n        } else if (this.getState() == AS3ParseState.CLASS_NAME) {\n          currToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]);\n          tmpToken = AS3Parser.nextWord(src, index, AS3Pattern.CURLY_BRACE[0], AS3Pattern.CURLY_BRACE[1]);\n          index = currToken.index;\n          if (!currToken.token || !tmpToken.token) {\n            throw new Error(\"Error parsing class name.\");\n          } else if (tmpToken.index < currToken.index) {\n            throw new Error(\"Error, no class name found before curly brace.\");\n          } else {\n            //Set the class name\n            cls.className = currToken.token;\n\n            // Update fully qualified class path if needed\n            this.classPath = this.classPath || AS3Parser.fixClassPath(cls.packageName + '.' + cls.className); //Remove extra \".\" for top level packages\n\n            cls.classMap[cls.className] = cls; //Register self into the import map (used for static detection)\n            //Now we will check for parent class and any interfaces\n            currToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]);\n            if (currToken.token == 'extends' && currToken.index < tmpToken.index) {\n              index = currToken.index;\n              currToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]);\n              index = currToken.index;\n              //The token following 'extends' must be the parent class\n              cls.parent = currToken.token;\n              //Prep the next token\n              currToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]);\n              Main.debug(\"Found parent: \" + cls.parent);\n            }\n            if (currToken.token == 'implements' && currToken.index < tmpToken.index) {\n              index = currToken.index;\n              currToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]);\n              index = currToken.index;\n              //The token following 'implements' must be an interface\n              cls.interfaces.push(currToken.token);\n              Main.debug(\"Found interface: \" + currToken.token);\n              currToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]);\n              //While we are at a token before the next curly brace\n              while (currToken.index < tmpToken.index && currToken.index < src.length) {\n                //Consider self token another interface being implemented\n                index = currToken.index;\n                Main.debug(\"Found interface: \" + currToken.token);\n                cls.interfaces.push(currToken.token);\n                currToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]);\n                index = currToken.index;\n              }\n            }\n            Main.debug('Parsed class name: ' + cls.className);\n            //Now parsing inside of the class\n            this.stack.push(AS3ParseState.CLASS);\n            Main.debug('Attempting to parse class...');\n\n            //Extract out the next method block\n            AS3Parser.PREVIOUS_BLOCK = cls.className + \":Class\";\n            tmpStr = AS3Parser.extractBlock(src, index)[0];\n            index += tmpStr.length - 1;\n\n            //Recursively call parseHelper again under this new state (Once returned, package will be exited)\n            this.parseHelper(cls, tmpStr);\n          }\n        } else if (this.getState() == AS3ParseState.CLASS) {\n          currMember = currMember || new AS3Member(); //Declare a new member to work with if it doesn't exist yet\n          currToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]);\n          index = currToken.index - 1;\n          if (currToken.token == AS3Encapsulation.PUBLIC || currToken.token == AS3Encapsulation.PRIVATE || currToken.token == AS3Encapsulation.PROTECTED) {\n            currMember.encapsulation = currToken.token;\n            Main.debug('->Member encapsulation set to ' + currMember.encapsulation);\n          } else if (currToken.token == 'static') {\n            currMember.isStatic = true;\n            Main.debug('-->Static flag set');\n          } else if (currToken.token == AS3MemberType.VAR || currToken.token == AS3MemberType.CONST) {\n            Main.debug('--->Member type \"variable\" set.');\n            currMember = currMember.createVariable(); //Transform the member into a variable\n            this.stack.push(AS3ParseState.MEMBER_VARIABLE);\n          } else if (currToken.token == AS3MemberType.FUNCTION) {\n            currToken = AS3Parser.nextWord(src, index + 1, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]);\n            //Check for getter/setter\n            if ((currToken.token == 'get' || currToken.token == 'set') && src[index + 1 + currToken.token.length + 1] != '(') {\n              Main.debug('--->Member sub-type \"' + currToken.token + '\" set.');\n              currMember.subType = currToken.token;\n              index = currToken.index - 1;\n            }\n            currMember = currMember.createFunction(); //Transform the member into a function\n            this.stack.push(AS3ParseState.MEMBER_FUNCTION);\n            Main.debug('---->Member type \"function\" set.');\n          }\n        } else if (this.getState() == AS3ParseState.MEMBER_VARIABLE) {\n          currToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]);\n          currMember.name = currToken.token; //Set the member name\n          Main.debug('---->Variable name declared: ' + currToken.token);\n          index = currToken.index;\n          if (src.charAt(index) == \":\") {\n            currToken = AS3Parser.nextWord(src, index, AS3Pattern.VARIABLE_TYPE[0], AS3Pattern.VARIABLE_TYPE[1]);\n            index = currToken.index;\n            currMember.type = currToken.token; //Set the value type name\n            Main.debug('---->Variable type for ' + currMember.name + ' declared as: ' + currToken.token);\n          }\n          currToken = AS3Parser.nextWord(src, index, AS3Pattern.ASSIGN_START[0], AS3Pattern.ASSIGN_START[1]);\n          if (currToken.token == \"=\") {\n            //Use all characters after self symbol to set value\n            index = currToken.index;\n            tmpArr = AS3Parser.extractUpTo(src, index, /[;\\r\\n]/g);\n            //Store value\n            currMember.value = tmpArr[0].trim();\n            index = tmpArr[1];\n\n            cls.membersWithAssignments.push(currMember);\n          }\n\n          //Store and delete current member and exit\n          if (currMember.isStatic) {\n            cls.staticMembers.push(currMember);\n          } else {\n            cls.members.push(currMember);\n          }\n          cls.registerField(currMember.name, currMember);\n          currMember = null;\n          this.stack.pop();\n        } else if (this.getState() == AS3ParseState.MEMBER_FUNCTION) {\n          //Parse the arguments\n          currToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]);\n          index = currToken.index;\n          currMember.name = currToken.token; //Set the member name\n          Main.debug('****>Function name declared: ' + currToken.token);\n\n          AS3Parser.PREVIOUS_BLOCK = currMember.name + \":Function\";\n          tmpArr = AS3Parser.extractBlock(src, index, '(', ')');\n          index = tmpArr[1] - 1; //Ending index of parsed block\n          tmpStr = tmpArr[0].trim(); //Parsed block\n          tmpStr = tmpStr.substr(1, tmpStr.length - 2); //Remove outer parentheses\n          tmpArr = null; //Trash this\n          tmpArr = tmpStr.split(','); //Split args by commas\n          //Don't bother if there are no arguments\n          if (tmpArr.length > 0 && tmpArr[0] != '') {\n            //Truncate spaces and assign values to arguments as needed\n            for (i = 0; i < tmpArr.length; i++) {\n              tmpStr = tmpArr[i];\n              //Grab the function name\n              tmpToken = AS3Parser.nextWord(tmpStr, 0, AS3Pattern.VARIABLE[0], AS3Pattern.VARIABLE[1]); //Parse out the function name\n              currMember.argList.push(new AS3Argument());\n              if (tmpStr.indexOf('...') === 0) {\n                //This is a ...rest argument, stop here\n                currMember.argList[currMember.argList.length - 1].name = tmpStr.substr(3);\n                currMember.argList[currMember.argList.length - 1].isRestParam = true;\n                Main.debug('----->Parsed a ...rest param: ' + currMember.argList[currMember.argList.length - 1].name);\n                break;\n              } else {\n                currMember.argList[currMember.argList.length - 1].name = tmpToken.token; //Set the argument name\n                Main.debug('----->Function argument found: ' + tmpToken.token);\n                //If a colon was next, we'll assume it was typed and grab it\n                if (tmpToken.index < tmpStr.length && tmpStr.charAt(tmpToken.index) == ':') {\n                  tmpToken = AS3Parser.nextWord(tmpStr, tmpToken.index, AS3Pattern.VARIABLE_TYPE[0], AS3Pattern.VARIABLE_TYPE[1]); //Parse out the argument type\n                  currMember.argList[currMember.argList.length - 1].type = tmpToken.token; //Set the argument type\n                  Main.debug('----->Function argument typed to: ' + tmpToken.token);\n                }\n                tmpToken = AS3Parser.nextWord(tmpStr, tmpToken.index, AS3Pattern.ASSIGN_START[0], AS3Pattern.ASSIGN_START[1]);\n                if (tmpToken.token == \"=\") {\n                  //Use all characters after self symbol to set value\n                  tmpToken = AS3Parser.nextWord(tmpStr, tmpToken.index, AS3Pattern.ASSIGN_UPTO[0], AS3Pattern.ASSIGN_UPTO[1]);\n                  if (!tmpToken) {\n                    throw new Error(\"Error during variable assignment in arg\" + currMember.argList[currMember.argList.length - 1].name);\n                  }\n                  //Store value\n                  currMember.argList[currMember.argList.length - 1].value = tmpToken.token.trim();\n                  Main.debug('----->Function argument defaulted to: ' + tmpToken.token.trim());\n                }\n              }\n            }\n          }\n          Main.debug('------>Completed paring args: ', currMember.argList);\n          //Type the function if needed\n          if (src.charAt(index + 1) == \":\") {\n            tmpToken = AS3Parser.nextWord(src, index + 1, AS3Pattern.VARIABLE_TYPE[0], AS3Pattern.VARIABLE_TYPE[1]); //Parse out the function type if needed\n            index = tmpToken.index;\n            currMember.type = tmpToken.token;\n            Main.debug('------>Typed the function to: ', currMember.type);\n          }\n\n          if (cls.isInterface) {\n            //Store and delete current member and exit\n            currMember.value = '{}';\n            if (currMember.subType == 'get') {\n              (currMember.isStatic) ? cls.staticGetters.push(currMember): cls.getters.push(currMember);\n            } else if (currMember.subType == 'set') {\n              (currMember.isStatic) ? cls.staticSetters.push(currMember): cls.setters.push(currMember);\n            } else if (currMember.isStatic) {\n              cls.staticMembers.push(currMember);\n            } else {\n              cls.members.push(currMember);\n            }\n            cls.registerField(currMember.name, currMember);\n            //Done parsing function\n            currMember = null;\n            this.stack.pop();\n          } else {\n            //Save the function body\n            AS3Parser.PREVIOUS_BLOCK = currMember.name + \":Function\";\n            tmpArr = AS3Parser.extractBlock(src, index);\n            index = tmpArr[1];\n            currMember.value = tmpArr[0].trim();\n\n            //Store and delete current member and exit\n            if (currMember.subType == 'get') {\n              (currMember.isStatic) ? cls.staticGetters.push(currMember): cls.getters.push(currMember);\n            } else if (currMember.subType == 'set') {\n              (currMember.isStatic) ? cls.staticSetters.push(currMember): cls.setters.push(currMember);\n            } else if (currMember.isStatic) {\n              cls.staticMembers.push(currMember);\n            } else {\n              cls.members.push(currMember);\n            }\n            cls.registerField(currMember.name, currMember);\n\n            currMember = null;\n            this.stack.pop();\n          }\n        } else if (this.getState() == AS3ParseState.LOCAL_VARIABLE) {\n\n        } else if (this.getState() == AS3ParseState.LOCAL_FUNCTION) {\n\n        } else if (this.getState() == AS3ParseState.IMPORT_PACKAGE) {\n          //The current token is a class import\n          currToken = AS3Parser.nextWord(src, index, AS3Pattern.IMPORT[0], AS3Pattern.IMPORT[1]);\n          index = currToken.index - 1;\n          if (!currToken.token) {\n            throw new Error(\"Error parsing import.\");\n          } else {\n            Main.debug(\"Parsed import name: \" + currToken.token);\n            if (currToken.token.indexOf(\"*\") >= 0) {\n              cls.importWildcards.push(currToken.token); //To be resolved later\n            } else {\n              cls.imports.push(currToken.token); //No need to resolve\n            }\n            this.stack.push(AS3ParseState.PACKAGE);\n          }\n        } else if (this.getState() == AS3ParseState.REQUIRE_MODULE) {\n          //The current token is a module requirement\n          currToken = AS3Parser.nextWord(src, index, AS3Pattern.REQUIRE[0], AS3Pattern.REQUIRE[1]);\n          index = currToken.index - 1;\n          if (!currToken.token)\n            throw new Error(\"Error parsing require.\");\n          else {\n            Main.debug(\"Parsed require name: \" + currToken.token);\n            cls.requires.push(currToken.token.trim());\n            this.stack.push(AS3ParseState.PACKAGE);\n          }\n        }\n      }\n    };\n    AS3Parser.prototype.parse = function(options) {\n      options = AS3JS.Utils.getDefaultValue(options, null);\n      options = options || {};\n      if (typeof options.safeRequire !== 'undefined') {\n        this.parserOptions.safeRequire = options.safeRequire;\n      }\n      if (typeof options.ignoreFlash !== 'undefined') {\n        this.parserOptions.ignoreFlash = options.ignoreFlash;\n      }\n\n      var classDefinition = new AS3Class(this.parserOptions);\n      this.stack.splice(0, this.stack.length);\n      this.stack.push(AS3ParseState.START);\n\n      this.parseHelper(classDefinition, this.src);\n\n      if (!classDefinition.className) {\n        throw new Error(\"Error, no class provided for package: \" + this.classPath);\n      }\n      return classDefinition;\n    }\n\n    module.exports = AS3Parser;\n  };\n  Program[\"com.mcleodgaming.as3js.parser.AS3Token\"] = function(module, exports) {\n    var AS3Token = function(token, index, extra) {\n      this.$init();\n      this.token = token;\n      this.index = index;\n      this.extra = extra;\n    };\n\n    AS3Token.prototype.$init = function() {};\n    AS3Token.prototype.token = null;\n    AS3Token.prototype.index = 0;\n    AS3Token.prototype.extra = null\n\n    module.exports = AS3Token;\n  };\n  Program[\"com.mcleodgaming.as3js.types.AS3Argument\"] = function(module, exports) {\n    var AS3Variable = module.import('com.mcleodgaming.as3js.types', 'AS3Variable');\n\n    var AS3Argument = function() {\n      this.$init();\n\n    };\n\n    AS3Argument.prototype = Object.create(AS3Variable.prototype);\n\n    AS3Argument.prototype.$init = function() {};\n    AS3Argument.prototype.isRestParam = false\n\n    module.exports = AS3Argument;\n  };\n  Program[\"com.mcleodgaming.as3js.types.AS3Function\"] = function(module, exports) {\n    var AS3Member = module.import('com.mcleodgaming.as3js.types', 'AS3Member');\n    var AS3Variable;\n    module.inject = function() {\n      AS3Variable = module.import('com.mcleodgaming.as3js.types', 'AS3Variable');\n    };\n\n    var AS3Function = function() {\n      this.$init();\n      this.argList = [];\n    };\n\n    AS3Function.prototype = Object.create(AS3Member.prototype);\n\n    AS3Function.prototype.$init = function() {\n      this.argList = null;\n    };\n    AS3Function.prototype.argList = null;\n    AS3Function.prototype.hasArgument = function() {\n      for (var i = 0; i < this.argList.length; i++)\n        if (this.argList[i].name == this.name)\n          return true;\n      return false;\n    };\n    AS3Function.prototype.buildLocalVariableStack = function() {\n      var i;\n      var text = this.value || '';\n      var matches = text.match(/(var|,)(.*?)([a-zA-Z_$][0-9a-zA-Z_$]*):([a-zA-Z_$][0-9a-zA-Z_$]*)/g);\n      var locals = [];\n      if (this.argList) {\n        for (i in this.argList) {\n          locals.push(this.argList[i]);\n        }\n      }\n      for (i in matches) {\n        var tmpVar = new AS3Variable();\n        tmpVar.name = matches[i].replace(/(var|,)(.*?)([a-zA-Z_$][0-9a-zA-Z_$]*):([a-zA-Z_$][0-9a-zA-Z_$]*)/g, \"$3\");\n        tmpVar.type = matches[i].replace(/(var|,)(.*?)([a-zA-Z_$][0-9a-zA-Z_$]*):([a-zA-Z_$][0-9a-zA-Z_$]*)/g, \"$4\");\n        locals.push(tmpVar);\n      }\n\n      return locals;\n    }\n\n    module.exports = AS3Function;\n  };\n  Program[\"com.mcleodgaming.as3js.types.AS3Member\"] = function(module, exports) {\n    var AS3Function, AS3Variable;\n    module.inject = function() {\n      AS3Function = module.import('com.mcleodgaming.as3js.types', 'AS3Function');\n      AS3Variable = module.import('com.mcleodgaming.as3js.types', 'AS3Variable');\n    };\n\n    var AS3Member = function() {\n      this.$init();\n      this.name = null;\n      this.type = '*';\n      this.subType = null,\n        this.value = null;\n      this.encapsulation = \"public\";\n      this.isStatic = false;\n    };\n\n    AS3Member.prototype.$init = function() {};\n    AS3Member.prototype.name = null;\n    AS3Member.prototype.type = null;\n    AS3Member.prototype.subType = null;\n    AS3Member.prototype.value = null;\n    AS3Member.prototype.encapsulation = null;\n    AS3Member.prototype.isStatic = false;\n    AS3Member.prototype.createVariable = function() {\n      var obj = new AS3Variable();\n      obj.name = this.name;\n      obj.type = this.type;\n      obj.subType = this.subType,\n        obj.value = this.value;\n      obj.encapsulation = this.encapsulation;\n      obj.isStatic = this.isStatic;\n      return obj;\n    };\n    AS3Member.prototype.createFunction = function() {\n      var obj = new AS3Function();\n      obj.name = this.name;\n      obj.type = this.type;\n      obj.subType = this.subType,\n        obj.value = this.value;\n      obj.encapsulation = this.encapsulation;\n      obj.isStatic = this.isStatic;\n      return obj;\n    }\n\n    module.exports = AS3Member;\n  };\n  Program[\"com.mcleodgaming.as3js.types.AS3Variable\"] = function(module, exports) {\n    var AS3Member = module.import('com.mcleodgaming.as3js.types', 'AS3Member');\n\n    var AS3Variable = function() {\n      this.$init();\n\n    };\n\n    AS3Variable.prototype = Object.create(AS3Member.prototype);\n\n    AS3Variable.prototype.$init = function() {}\n\n    module.exports = AS3Variable;\n  };\n  if (typeof module !== 'undefined') {\n    module.exports = AS3JS.load({\n      program: Program,\n      entry: \"com.mcleodgaming.as3js.Main\",\n      entryMode: \"static\"\n    });\n  } else if (typeof window !== 'undefined' && typeof AS3JS !== 'undefined') {\n    window['com.mcleodgaming.as3js.Main'] = AS3JS.load({\n      program: Program,\n      entry: \"com.mcleodgaming.as3js.Main\",\n      entryMode: \"static\"\n    });\n  }\n})();"
  },
  {
    "path": "snippets/class-snippet.js",
    "content": "Program[\"{{module}}\"] = function ( module, exports ) {\n{{source}}\n};\n"
  },
  {
    "path": "snippets/main-snippet.js",
    "content": "(function ( ) {\n  var Program = {};\n{{packages}}\n\n  if (typeof module !== 'undefined') {\n    module.exports = AS3JS.load({ program: Program, entry: \"{{entryPoint}}\", entryMode: \"{{entryMode}}\" });\n  } else if (typeof window !== 'undefined' && typeof AS3JS !== 'undefined') {\n    window['{{entryPoint}}'] = AS3JS.load({ program: Program, entry: \"{{entryPoint}}\", entryMode: \"{{entryMode}}\" });\n  }\n})();"
  },
  {
    "path": "src/com/mcleodgaming/as3js/Main.as",
    "content": "package com.mcleodgaming.as3js\n{\n\timport com.mcleodgaming.as3js.parser.AS3Class;\n\timport com.mcleodgaming.as3js.parser.AS3Parser;\n\trequire \"path\"\n\trequire \"fs\"\n\t\n\tpublic class Main \n\t{\n\t\tpublic static var DEBUG_MODE:Boolean = false;\n\t\tpublic static var SILENT:Boolean = false;\n\t\tpublic static function debug():void\n\t\t{\n\t\t\tif (Main.SILENT)\n\t\t\t{\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (Main.DEBUG_MODE)\n\t\t\t{\n\t\t\t\tconsole.log.apply(console, arguments);\n\t\t\t}\n\t\t}\n\t\tpublic static function log():void\n\t\t{\n\t\t\tif (Main.SILENT)\n\t\t\t{\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconsole.log.apply(console, arguments);\n\t\t}\n\t\tpublic static function warn():void\n\t\t{\n\t\t\tif (Main.SILENT)\n\t\t\t{\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconsole.warn.apply(console, arguments);\n\t\t}\n\t\t\n\t\tpublic function Main() \n\t\t{\n\t\t\t\n\t\t}\n\t\t\n\t\tpublic function compile(options:Object = null):Object\n\t\t{\n\t\t\tvar packages:Object = { }; //Will contain the final map of package names to source text\n\t\t\tvar i:*;\n\t\t\tvar j:*;\n\t\t\tvar k:*;\n\t\t\tvar m:*;\n\t\t\tvar tmp:String;\n\t\t\toptions = options || {};\n\t\t\tvar srcPaths:Object = options.srcPaths || {};\n\t\t\tvar rawPackages:Array = options.rawPackages || [];\n\t\t\tvar parserOptions:Object = { safeRequire: options.safeRequire, ignoreFlash: options.ignoreFlash};\n\t\t\t\n\t\t\t//Temp classes for holding raw class info\n\t\t\tvar rawClass:AS3Class;\n\t\t\tvar rawParser:AS3Parser;\n\t\t\t\n\t\t\tvar pkgLists:Object = {};\n\t\t\tfor (i in srcPaths)\n\t\t\t{\n\t\t\t\tpkgLists[srcPaths[i]] = buildPackageList(srcPaths[i]);\n\t\t\t}\n\n\t\t\tMain.DEBUG_MODE = options.verbose || Main.DEBUG_MODE;\n\t\t\tMain.SILENT = options.silent || Main.SILENT;\n\n\t\t\tvar classes:Object = {};\n\t\t\tvar buffer:String = \"\";\n\t\t\t\n\t\t\t//First, parse through the file-based classes and get the basic information\n\t\t\tfor (i in pkgLists)\n\t\t\t{\n\t\t\t\tfor (j in pkgLists[i])\n\t\t\t\t{\n\t\t\t\t\tMain.log('Analyzing class path: ' + pkgLists[i][j].classPath);\n\t\t\t\t\tclasses[pkgLists[i][j].classPath] = pkgLists[i][j].parse(parserOptions);\n\t\t\t\t\tMain.debug(classes[pkgLists[i][j].classPath]);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t// Now parse through any raw string classes\n\t\t\tfor (i = 0; i < rawPackages.length; i++)\n\t\t\t{\n\t\t\t\tMain.log('Analyzing class: ' + i);\n\t\t\t\trawParser = new AS3Parser(rawPackages[i]);\n\t\t\t\trawClass = rawParser.parse(parserOptions);\n\t\t\t\tclasses[rawParser.classPath] = rawClass;\n\t\t\t}\n\n\t\t\t//Resolve all possible package name wildcards\n\t\t\tfor (i in classes)\n\t\t\t{\n\t\t\t\t//For every class\n\t\t\t\tfor (j in classes[i].importWildcards)\n\t\t\t\t{\n\t\t\t\t\tMain.debug('Resolving ' + classes[i].className + '\\'s ' + classes[i].importWildcards[j] + ' ...')\n\t\t\t\t\t//For every wild card in the class\n\t\t\t\t\tfor (k in srcPaths)\n\t\t\t\t\t{\n\t\t\t\t\t\t//For each possible source path (should hopefully just be 1 most of the time -_-)\n\t\t\t\t\t\ttmp = srcPaths[k] + path.sep + classes[i].importWildcards[j].replace(/\\./g, path.sep).replace(path.sep+'*', '');\n\t\t\t\t\t\ttmp = tmp.replace(/\\\\/g, '/'); \n\t\t\t\t\t\ttmp = tmp.replace(/[\\/]/g, path.sep); \n\t\t\t\t\t\tif(fs.existsSync(tmp)) {\n\t\t\t\t\t\t\tMain.debug('Searching path ' + tmp + '...')\n\t\t\t\t\t\t\t//Path exists, read the files in the directory\n\t\t\t\t\t\t\tvar files = fs.readdirSync(tmp);\n\t\t\t\t\t\t\tfor(m in files) {\n\t\t\t\t\t\t\t\t//See if this is an ActionScript file\n\t\t\t\t\t\t\t\tif(fs.statSync(tmp + path.sep + files[m]).isFile() && files[m].lastIndexOf('.as') == files[m].length - 3) {\n\t\t\t\t\t\t\t\t\t//See if the class needs the file\n\t\t\t\t\t\t\t\t\tif(classes[i].needsImport(classes[i].importWildcards[j].replace(/\\*/g, files[m].substr(0, files[m].length - 3)))) {\n\t\t\t\t\t\t\t\t\t\tMain.debug('Auto imported ' + files[m].substr(0, files[m].length - 3));\n\t\t\t\t\t\t\t\t\t\tclasses[i].addImport(classes[i].importWildcards[j].replace(/\\*/g, files[m].substr(0, files[m].length - 3))); //Pass in package name with wild card replaced\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tMain.warn('Warning, could not find directory: ' + tmp);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Must do again for classes in case there we\n\t\t\t\t\tfor (k in classes)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(classes[i].needsImport(AS3Parser.fixClassPath(classes[k].packageName + '.' + classes[k].className))) {\n\t\t\t\t\t\t\tMain.debug('Auto imported ' + AS3Parser.fixClassPath(classes[k].packageName + '.' + classes[k].className));\n\t\t\t\t\t\t\tclasses[i].addImport(AS3Parser.fixClassPath(classes[k].packageName + '.' + classes[k].className)); //Pass in package name with wild card replaced\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t//Add extra imports before registring them (these will not be imported in the output code, but rather will provide insight for AS3JS to determine variable types)\n\t\t\tfor (i in classes)\n\t\t\t{\n\t\t\t\tfor (j in classes)\n\t\t\t\t{\n\t\t\t\t\tclasses[i].addExtraImport(AS3Parser.fixClassPath(classes[j].packageName + '.' + classes[j].className));\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t//Resolve import map\n\t\t\tfor (i in classes)\n\t\t\t{\n\t\t\t\tclasses[i].registerImports(classes);\n\t\t\t}\n\n\t\t\t//Resolve parent imports\n\t\t\tfor (i in classes)\n\t\t\t{\n\t\t\t\tclasses[i].findParents(classes);\n\t\t\t}\n\t\t\t\n\t\t\t//Walk through the class members that had assignments in the class scope\n\t\t\tfor (i in classes)\n\t\t\t{\n\t\t\t\tclasses[i].checkMembersWithAssignments();\n\t\t\t}\n\t\t\t\t\n\t\t\t//Process the function text to comply with JS\n\t\t\tfor (i in classes)\n\t\t\t{\n\t\t\t\tMain.log('Parsing package: ' + AS3Parser.fixClassPath(classes[i].packageName + \".\" + classes[i].className));\n\t\t\t\tclasses[i].process(classes);\n\t\t\t}\n\t\t\t// Load stringified versions of snippets/main-snippet.js and snippets/class-snippet.js\n\t\t\tvar mainTemplate:String = \"(function(){var Program={};{{packages}}if(typeof module !== 'undefined'){module.exports=AS3JS.load({program:Program,entry:\\\"{{entryPoint}}\\\",entryMode:\\\"{{entryMode}}\\\"});}else if(typeof window!=='undefined'&&typeof AS3JS!=='undefined'){window['{{entryPoint}}']=AS3JS.load({program:Program,entry:\\\"{{entryPoint}}\\\",entryMode:\\\"{{entryMode}}\\\"});}})();\";\n\t\t\tvar classTemplate:String = \"Program[\\\"{{module}}\\\"]=function(module, exports){{{source}}};\";\n\t\t\tvar packageObjects:Array = [];\n\t\t\tvar classObjects:Array = null;\n\t\t\tvar currentClass:String = \"\";\n\t\t\t\n\t\t\tif (options.entry)\n\t\t\t{\n\t\t\t\t// Entry point should be in the format \"mode:path.to.package.Class\"\n\t\t\t\tvar currentPackage:String = options.entry;\n\t\t\t\tvar mode:String = options.entryMode || 'instance';\n\t\t\t\t// Update template with entry points\n\t\t\t\tmainTemplate = mainTemplate.replace(/\\{\\{entryPoint\\}\\}/g, AS3Parser.fixClassPath(classes[currentPackage].packageName + '.' + classes[currentPackage].className));\n\t\t\t\tmainTemplate = mainTemplate.replace(/\\{\\{entryMode\\}\\}/g, mode);\n\t\t\t} else\n\t\t\t{\n\t\t\t\tmainTemplate = mainTemplate.replace(/\\{\\{entryPoint\\}\\}/g, \"\");\n\t\t\t\tmainTemplate = mainTemplate.replace(/\\{\\{entryMode\\}\\}/g, \"\");\n\t\t\t}\n\t\t\t\n\t\t\t//Retrieve converted class code\n\t\t\tvar groupByPackage:Object = { };\n\t\t\tfor (i in classes)\n\t\t\t{\n\t\t\t\tgroupByPackage[classes[i].packageName] = groupByPackage[classes[i].packageName] || [];\n\t\t\t\tgroupByPackage[classes[i].packageName].push(classes[i]);\n\t\t\t}\n\t\t\tfor (i in groupByPackage)\n\t\t\t{\n\t\t\t\tclassObjects = [];\n\t\t\t\tfor (j in groupByPackage[i])\n\t\t\t\t{\n\t\t\t\t\tpackages[AS3Parser.fixClassPath(i+\".\"+groupByPackage[i][j].className)] = groupByPackage[i][j].toString();\n\t\t\t\t\tcurrentClass = classTemplate;\n\t\t\t\t\tcurrentClass = currentClass.replace(/\\{\\{module\\}\\}/g, AS3Parser.fixClassPath(groupByPackage[i][j].packageName + \".\" + groupByPackage[i][j].className));\n\t\t\t\t\tcurrentClass = currentClass.replace(/\\{\\{source\\}\\}/g, AS3Parser.increaseIndent(packages[AS3Parser.fixClassPath(i+\".\"+groupByPackage[i][j].className)], \"  \"));\n\t\t\t\t\tclassObjects.push(currentClass);\n\t\t\t\t}\n\t\t\t\tpackageObjects.push(AS3Parser.increaseIndent(classObjects.join(\"\"), \"  \"));\n\t\t\t}\n\t\t\t\n\t\t\tmainTemplate = mainTemplate.replace(/\\{\\{packages\\}\\}/g, packageObjects.join(\"\"));\n\t\t\t\n\t\t\tmainTemplate = mainTemplate.replace(/\\t/g, \"  \");\n\t\t\t\n\t\t\tbuffer += mainTemplate;\n\t\t\t\n\t\t\tMain.log(\"Done.\");\n\t\t\t\n\t\t\treturn { compiledSource: buffer, packageSources: packages };\n\t\t}\n\t\tprivate function readDirectory(location:String, pkgBuffer:String, obj:Object):void\n\t\t{\n\t\t\tvar files:Array = fs.readdirSync(location);\n\t\t\tfor (var i in files)\n\t\t\t{\n\t\t\t\tvar pkg:String = pkgBuffer;\n\t\t\t\tif (fs.statSync(location + path.sep + files[i]).isDirectory())\n\t\t\t\t{\n\t\t\t\t\tvar splitPath:Array = location.split(path.sep);\n\t\t\t\t\tif (pkg != '')\n\t\t\t\t\t{\n\t\t\t\t\t\tpkg += '.';\n\t\t\t\t\t}\n\t\t\t\t\tthis.readDirectory(location + path.sep + files[i], pkg + files[i], obj)\n\t\t\t\t} else if (fs.statSync(location + path.sep + files[i]).isFile() && files[i].lastIndexOf('.as') == files[i].length - 3)\n\t\t\t\t{\n\t\t\t\t\tif (pkg != '')\n\t\t\t\t\t{\n\t\t\t\t\t\tpkg += '.';\n\t\t\t\t\t}\n\t\t\t\t\tpkg += files[i].substr(0, files[i].length - 3);\n\t\t\t\t\tvar f = fs.readFileSync(location + path.sep + files[i]);\n\t\t\t\t\tobj[pkg] = new AS3Parser(f.toString(), pkg);\n\t\t\t\t\tMain.debug(\"Loaded file: \", location + path.sep + files[i] + \" (package: \" + pkg + \")\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tpublic function buildPackageList(location:String):void\n\t\t{\n\t\t\tvar obj:Object = {};\n\t\t\tvar topLevel:String = location;\n\t\t\tlocation = location.replace(/\\\\/g, '/'); \n\t\t\tlocation = location.replace(/[\\/]/g, path.sep); \n\t\t\tif (fs.existsSync(location) && fs.statSync(location).isDirectory())\n\t\t\t{\n\t\t\t\tvar splitPath = location.split(path.sep);\n\t\t\t\treadDirectory(location, '', obj);\n\t\t\t\treturn obj;\n\t\t\t} else\n\t\t\t{\n\t\t\t\tthrow new Error(\"Error could not find directory: \" + location);\n\t\t\t}\n\t\t}\n\t}\n\n}"
  },
  {
    "path": "src/com/mcleodgaming/as3js/enums/AS3Encapsulation.as",
    "content": "package com.mcleodgaming.as3js.enums\n{\n\tpublic class AS3Encapsulation \n\t{\n\t\tpublic static const PUBLIC:String = \"public\";\n\t\tpublic static const PRIVATE:String = \"private\";\n\t\tpublic static const PROTECTED:String = \"protected\";\n\t}\n}"
  },
  {
    "path": "src/com/mcleodgaming/as3js/enums/AS3MemberType.as",
    "content": "package com.mcleodgaming.as3js.enums\n{\n\tpublic class AS3MemberType \n\t{\n\t\tpublic static const VAR:String = \"var\";\n\t\tpublic static const CONST:String = \"const\";\n\t\tpublic static const FUNCTION:String = \"function\";\n\t}\n}"
  },
  {
    "path": "src/com/mcleodgaming/as3js/enums/AS3ParseState.as",
    "content": "package com.mcleodgaming.as3js.enums\n{\n\tpublic class AS3ParseState \n\t{\n\t\tpublic static const START:String = \"start\";\n\t\tpublic static const PACKAGE_NAME:String = \"packageName\";\n\t\tpublic static const PACKAGE:String = \"package\";\n\t\tpublic static const CLASS_NAME:String = \"className\";\n\t\tpublic static const CLASS:String = \"class\";\n\t\tpublic static const CLASS_EXTENDS:String = \"classExtends\";\n\t\tpublic static const CLASS_IMPLEMENTS:String = \"classImplements\";\n\t\tpublic static const COMMENT_INLINE:String = \"commentInline\";\n\t\tpublic static const COMMENT_MULTILINE:String = \"commentMultiline\";\n\t\tpublic static const STRING_SINGLE_QUOTE:String = \"stringSingleQuote\";\n\t\tpublic static const STRING_DOUBLE_QUOTE:String = \"stringDoubleQuote\";\n\t\tpublic static const STRING_REGEX:String = \"stringRegex\";\n\t\tpublic static const MEMBER_VARIABLE:String = \"memberVariable\";\n\t\tpublic static const MEMBER_FUNCTION:String = \"memberFunction\";\n\t\tpublic static const LOCAL_VARIABLE:String = \"localVariable\";\n\t\tpublic static const LOCAL_FUNCTION:String = \"localFunction\";\n\t\tpublic static const IMPORT_PACKAGE:String = \"importPackage\";\n\t\tpublic static const REQUIRE_MODULE:String = \"requireModule\";\n\t}\n}"
  },
  {
    "path": "src/com/mcleodgaming/as3js/enums/AS3Pattern.as",
    "content": "package com.mcleodgaming.as3js.enums\n{\n\tpublic class AS3Pattern \n\t{\n\t\tpublic static const IDENTIFIER:Array = [ /\\w/g, /\\w/g ];\n\t\tpublic static const OBJECT:Array = [ /[\\w\\.]/g, /[\\w(\\w(\\.\\w)+)]/g ];\n\t\tpublic static const IMPORT:Array = [ /[0-9a-zA-Z_$.*]/g, /[a-zA-Z_$][0-9a-zA-Z_$]([.][a-zA-Z_$][0-9a-zA-Z_$])*\\*?/g ];\n\t\tpublic static const REQUIRE:Array = [ /./g, /[\"'](.*?)['\"]/g ];\n\t\tpublic static const CURLY_BRACE:Array = [ /[\\{|\\}]/g, /[\\{|\\}]/g ];\n\t\tpublic static const VARIABLE:Array = [ /[0-9a-zA-Z_$]/g, /[a-zA-Z_$][0-9a-zA-Z_$]*/g ];\n\t\tpublic static const VARIABLE_TYPE:Array = [ /[a-zA-Z_$<>.*][0-9a-zA-Z_$<>.]*/g, /[a-zA-Z_$<>.*][0-9a-zA-Z_$<>.]*/g ];\n\t\tpublic static const VARIABLE_DECLARATION:Array = [ /[0-9a-zA-Z_$:<>.*]/g, /[a-zA-Z_$][0-9a-zA-Z_$]*\\s*:\\s*([a-zA-Z_$<>\\.\\*][0-9a-zA-Z_$<>\\.]*)/g ];\n\t\tpublic static const ASSIGN_START:Array = [ /[=\\r\\n]/g, /[=\\r\\n]/g ];\n\t\tpublic static const ASSIGN_UPTO:Array = [ new RegExp(\"[^;\\\\r\\\\n]\", \"g\"), /(.*?)/g ];\n\t\tpublic static const VECTOR:Array = [ /new[\\s\\t]+Vector\\.<(.*?)>\\((.*?)\\)/g, /new[\\s\\t]+Vector\\.<(.*?)>\\((.*?)\\)/ ];\n\t\tpublic static const ARRAY:Array = [ /new[\\s\\t]+Array\\((.*?)\\)/g, /new[\\s\\t]+Array\\((.*?)\\)/ ];\n\t\tpublic static const DICTIONARY:Array = [ /new[\\s\\t]+Dictionary\\((.*?)\\)/g ];\n\t\tpublic static const REST_ARG:Array = [ /\\.\\.\\.[a-zA-Z_$][0-9a-zA-Z_$]*/g, /\\.\\.\\.[a-zA-Z_$][0-9a-zA-Z_$]*/g];\n\t}\n}"
  },
  {
    "path": "src/com/mcleodgaming/as3js/parser/AS3Class.as",
    "content": "package com.mcleodgaming.as3js.parser\n{\n\timport com.mcleodgaming.as3js.Main;\n\timport com.mcleodgaming.as3js.enums.*;\n\timport com.mcleodgaming.as3js.types.*;\n\t\n\tpublic class AS3Class \n\t{\n\t\tpublic static var reservedWords:Array = [\"as\", \"class\", \"delete\", \"false\", \"if\", \"instanceof\", \"native\", \"private\", \"super\", \"to\", \"use\", \"with\", \"break\", \"const\", \"do\", \"finally\", \"implements\", \"new\", \"protected\", \"switch\", \"true\", \"var\", \"case\", \"continue\", \"else\", \"for\", \"import\", \"internal\", \"null\", \"public\", \"this\", \"try\", \"void\", \"catch\", \"default\", \"extends\", \"function\", \"in\", \"is\", \"package\", \"return\", \"throw\", \"typeof\", \"while\", \"each\", \"get\", \"set\", \"namespace\", \"include\", \"dynamic\", \"final\", \"natiev\", \"override\", \"static\", \"abstract\", \"char\", \"export\", \"long\", \"throws\", \"virtual\", \"boolean\", \"debugger\", \"float\", \"prototype\", \"to\", \"volatile\", \"byte\", \"double\", \"goto\", \"short\", \"transient\", \"cast\", \"enum\", \"intrinsic\", \"synchronized\", \"type\"];\n\t\t\n\t\tpublic static var nativeTypes:Array = [\"Boolean\", \"Number\", \"int\", \"uint\", \"String\" ];\n\t\t\n\t\tpublic var packageName:String;\n\t\tpublic var className:String;\n\t\tpublic var imports:Vector.<String>;\n\t\tpublic var requires:Vector.<String>;\n\t\tpublic var importWildcards:Vector.<String>;\n\t\tpublic var importExtras:Vector.<String>;\n\t\tpublic var interfaces:Vector.<String>;\n\t\tpublic var parent:String;\n\t\tpublic var parentDefinition:AS3Class;\n\t\tpublic var members:Vector.<AS3Member>;\n\t\tpublic var staticMembers:Vector.<AS3Member>;\n\t\tpublic var getters:Vector.<AS3Member>;\n\t\tpublic var setters:Vector.<AS3Member>;\n\t\tpublic var staticGetters:Vector.<AS3Member>;\n\t\tpublic var staticSetters:Vector.<AS3Member>;\n\t\tpublic var isInterface:Boolean;\n\t\tpublic var membersWithAssignments:Vector.<AS3Member>; //List of class members that have assignments in the class-level scope\n\t\tpublic var fieldMap:Object; //Maps instance field names to instance members\n\t\tpublic var staticFieldMap:Object; //Maps static field names to static members\n\t\tpublic var classMap:Object; //Maps class shorthand name to class\n\t\tpublic var classMapFiltered:Object; //Same as classMap but only references classes that are actually used (i.e. used in another way besides just a \"type\")\n\t\tpublic var packageMap:Object; //Maps full package path to class\n\t\t\n\t\t// Options\n\t\tpublic var safeRequire:Boolean; //Try catch around parsed require statements\n\t\tpublic var ignoreFlash:Boolean; //Ignore FL imports\n\t\t\t\n\t\tpublic function AS3Class(options:Object = null) \n\t\t{\n\t\t\toptions = options || { };\n\t\t\tsafeRequire = false;\n\t\t\t\n\t\t\tif (typeof options.safeRequire !== 'undefined')\n\t\t\t{\n\t\t\t\tsafeRequire = options.safeRequire;\n\t\t\t}\n\t\t\tif (typeof options.ignoreFlash !== 'undefined')\n\t\t\t{\n\t\t\t\tignoreFlash = options.ignoreFlash;\n\t\t\t}\n\t\t\t\n\t\t\tpackageName = null;\n\t\t\tclassName = null;\n\t\t\timports = new Vector.<String>();\n\t\t\trequires = new Vector.<String>();\n\t\t\timportWildcards = new Vector.<String>();\n\t\t\timportExtras = new Vector.<String>();\n\t\t\tinterfaces = new Vector.<String>();\n\t\t\tparent = null;\n\t\t\tparentDefinition = null;\n\t\t\tmembers = new Vector.<AS3Member>();\n\t\t\tstaticMembers = new Vector.<AS3Member>();\n\t\t\tgetters = new Vector.<AS3Member>();\n\t\t\tsetters = new Vector.<AS3Member>();\n\t\t\tstaticGetters = new Vector.<AS3Member>();\n\t\t\tstaticSetters = new Vector.<AS3Member>();\n\t\t\tmembersWithAssignments = new Vector.<AS3Member>();\n\t\t\tisInterface = false;\n\t\t\tfieldMap = {};\n\t\t\tstaticFieldMap = {};\n\t\t\tclassMap = { };\n\t\t\tclassMapFiltered = { };\n\t\t\tpackageMap = { };\n\t\t\t\n\t\t\tvar $init:AS3Function = new AS3Function();\n\t\t\t$init.name = \"$init\";\n\t\t\t$init.value = \"{}\";\n\t\t\t$init.type === AS3MemberType.FUNCTION;\n\t\t\t$init.isStatic = false;\n\t\t\tmembers.push($init);\n\t\t\tregisterField($init.name, $init);\n\t\t}\n\t\tpublic function registerImports(clsList:Object):void\n\t\t{\n\t\t\tvar i;\n\t\t\tfor (i in imports)\n\t\t\t{\n\t\t\t\tif (clsList[imports[i]])\n\t\t\t\t{\n\t\t\t\t\tvar lastIndex:int = imports[i].lastIndexOf(\".\");\n\t\t\t\t\tvar shorthand:String = (lastIndex < 0) ? imports[i] : imports[i].substr(lastIndex + 1);\n\t\t\t\t\tclassMap[shorthand] = clsList[imports[i]];\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (i in importExtras)\n\t\t\t{\n\t\t\t\tif (clsList[importExtras[i]])\n\t\t\t\t{\n\t\t\t\t\tvar lastIndex:int = importExtras[i].lastIndexOf(\".\");\n\t\t\t\t\tvar shorthand:String = (lastIndex < 0) ? importExtras[i] : importExtras[i].substr(lastIndex + 1);\n\t\t\t\t\tclassMap[shorthand] = clsList[importExtras[i]];\n\t\t\t\t}\n\t\t\t}\n\t\t\tpackageMap = clsList;\n\t\t}\n\t\tpublic function registerField(name:String, value:AS3Member):void\n\t\t{\n\t\t\tif (value && value.isStatic)\n\t\t\t{\n\t\t\t\tstaticFieldMap[name] = staticFieldMap[name] || value;\n\t\t\t} else\n\t\t\t{\n\t\t\t\tfieldMap[name] = fieldMap[name] || value;\n\t\t\t}\n\t\t}\n\t\tpublic function retrieveField(name:String, isStatic:Boolean):AS3Member\n\t\t{\n\t\t\tif (isStatic)\n\t\t\t{\n\t\t\t\tif (staticFieldMap[name])\n\t\t\t\t{\n\t\t\t\t\treturn staticFieldMap[name];\n\t\t\t\t} else if (parentDefinition)\n\t\t\t\t{\n\t\t\t\t\treturn parentDefinition.retrieveField(name, isStatic);\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t} else\n\t\t\t{\n\t\t\t\tif (fieldMap[name])\n\t\t\t\t{\n\t\t\t\t\treturn fieldMap[name];\n\t\t\t\t} else if (parentDefinition)\n\t\t\t\t{\n\t\t\t\t\treturn parentDefinition.retrieveField(name, isStatic);\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tpublic function needsImport(pkg:String):Boolean\n\t\t{\n\t\t\tvar i:*;\n\t\t\tvar j:*;\n\t\t\tvar lastIndex:int = pkg.lastIndexOf(\".\");\n\t\t\tvar shorthand:String = (lastIndex < 0) ? pkg : pkg.substr(lastIndex + 1);\n\t\t\tvar matches:Vector.<AS3Member>;\n\n\t\t\tif (imports.indexOf(pkg) >= 0)\n\t\t\t{\n\t\t\t\treturn false; //Class was already imported\n\t\t\t}\n\n\t\t\tif (shorthand == className && pkg == packageName)\n\t\t\t{\n\t\t\t\treturn true; //Don't need self\n\t\t\t}\n\t\t\t\t\n\t\t\tif (shorthand == parent)\n\t\t\t{\n\t\t\t\treturn true; //Parent class is in another package\n\t\t\t}\n\t\t\t\n\t\t\t//Now we must parse through all members one by one, looking at functions and variable types to determine the necessary imports\n\t\t\t\t\n\t\t\tfor (i in members)\n\t\t\t{\n\t\t\t\t//See if the function definition or variable assigment have a need for this package\n\t\t\t\tif (members[i] instanceof AS3Function)\n\t\t\t\t{\n\t\t\t\t\tmatches = members[i].value.match(AS3Pattern.VARIABLE_DECLARATION[1]);\n\t\t\t\t\tfor (j in matches)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(matches[j].split(\":\")[1] == shorthand)\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tfor (j in members[i].argList)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(typeof members[i].argList[j].type == 'string' && members[i].argList[j].type == shorthand)\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (typeof members[i].value == 'string' && members[i].value.match(new RegExp(\"([^a-zA-Z_$.])\" + shorthand + \"([^0-9a-zA-Z_$])\", \"g\")))\n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t} else if (typeof members[i].type == 'string' && members[i].type == shorthand)\n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (i in staticMembers)\n\t\t\t{\n\t\t\t\t//See if the function definition or variable assigment have a need for this package\n\t\t\t\tif (staticMembers[i] instanceof AS3Function)\n\t\t\t\t{\n\t\t\t\t\tmatches = staticMembers[i].value.match(AS3Pattern.VARIABLE_DECLARATION[1]);\n\t\t\t\t\tfor (j in matches)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (matches[j].split(\":\")[1] == shorthand)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfor (j in staticMembers[i].argList) \n\t\t\t\t\t{\n\t\t\t\t\t\tif (typeof staticMembers[i].argList[j].type == 'string' && staticMembers[i].argList[j].type == shorthand)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (typeof staticMembers[i].value == 'string' && staticMembers[i].value.match(new RegExp(\"([^a-zA-Z_$.])\" + shorthand + \"([^0-9a-zA-Z_$])\", \"g\")))\n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t} else if (typeof staticMembers[i].type == 'string' && staticMembers[i].type == shorthand)\n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (i in getters)\n\t\t\t{\n\t\t\t\t//See if the function definition or variable assigment have a need for this package\n\t\t\t\tmatches = getters[i].value.match(AS3Pattern.VARIABLE_DECLARATION[1]);\n\t\t\t\tfor (j in matches)\n\t\t\t\t{\n\t\t\t\t\tif (matches[j].split(\":\")[1] == shorthand)\n\t\t\t\t\t{\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (j in getters[i].argList)\n\t\t\t\t{\n\t\t\t\t\tif (typeof getters[i].argList[j].type == 'string' && getters[i].argList[j].type == shorthand)\n\t\t\t\t\t{\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (typeof getters[i].value == 'string' && getters[i].value.match(new RegExp(\"([^a-zA-Z_$.])\" + shorthand + \"([^0-9a-zA-Z_$])\", \"g\")))\n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t} else if (typeof getters[i].type == 'string' && getters[i].type == shorthand)\n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (i in setters)\n\t\t\t{\n\t\t\t\tmatches = setters[i].value.match(AS3Pattern.VARIABLE_DECLARATION[1]);\n\t\t\t\tfor (j in matches)\n\t\t\t\t{\n\t\t\t\t\tif (matches[j].split(\":\")[1] == shorthand)\n\t\t\t\t\t{\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t//See if the function definition or variable assigment have a need for this package\n\t\t\t\tfor (j in setters[i].argList) \n\t\t\t\t{\n\t\t\t\t\tif (typeof setters[i].argList[j].type == 'string' && setters[i].argList[j].type == shorthand)\n\t\t\t\t\t{\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (typeof setters[i].value == 'string' && setters[i].value.match(new RegExp(\"([^a-zA-Z_$.])\" + shorthand + \"([^0-9a-zA-Z_$])\", \"g\")))\n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t} else if (typeof setters[i].type == 'string' && setters[i].type == shorthand)\n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (i in staticGetters)\n\t\t\t{\n\t\t\t\tmatches = staticGetters[i].value.match(AS3Pattern.VARIABLE_DECLARATION[1]);\n\t\t\t\tfor (j in matches)\n\t\t\t\t{\n\t\t\t\t\tif (matches[j].split(\":\")[1] == shorthand)\n\t\t\t\t\t{\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t//See if the function definition or variable assigment have a need for this package\n\t\t\t\tfor (j in staticGetters[i].argList)\n\t\t\t\t{\n\t\t\t\t\tif (typeof staticGetters[i].argList[j].type == 'string' && staticGetters[i].argList[j].type == shorthand)\n\t\t\t\t\t{\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (typeof staticGetters[i].value == 'string' && staticGetters[i].value.match(new RegExp(\"([^a-zA-Z_$.])\" + shorthand + \"([^0-9a-zA-Z_$])\", \"g\")))\n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t} else if (typeof staticGetters[i].type == 'string' && staticGetters[i].type == shorthand)\n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (i in staticSetters)\n\t\t\t{\n\t\t\t\tmatches = staticSetters[i].value.match(AS3Pattern.VARIABLE_DECLARATION[1]);\n\t\t\t\tfor (j in matches)\n\t\t\t\t{\n\t\t\t\t\tif (matches[j].split(\":\")[1] == shorthand)\n\t\t\t\t\t{\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (j in staticSetters[i].argList)\n\t\t\t\t{\n\t\t\t\t\tif (typeof staticSetters[i].argList[j].type == 'string' && staticSetters[i].argList[j].type == shorthand)\n\t\t\t\t\t{\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t//See if the function definition or variable assigment have a need for this package\n\t\t\t\tif (typeof staticSetters[i].value == 'string' && staticSetters[i].value.match(new RegExp(\"([^a-zA-Z_$.])\" + shorthand + \"([^0-9a-zA-Z_$])\", \"g\")))\n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t} else if (typeof staticSetters[i].type == 'string' && staticSetters[i].type == shorthand)\n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tvar classMember:AS3Member;\n\t\t\t// Same logic as checkMembersWithAssignments()\n\t\t\t// For each member that has an assignment at the top-level scope\n\t\t\tfor (i = 0; i < membersWithAssignments.length; i++)\n\t\t\t{\n\t\t\t\tclassMember = membersWithAssignments[i];\n\t\t\t\t// Make a dumb attempt to identify use of the class as assignments here\n\t\t\t\tif (classMember.value && classMember.value.indexOf(shorthand) >= 0 && !(parentDefinition && parentDefinition.packageName + \".\" + parentDefinition.className === pkg))\n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\treturn false;\n\t\t}\n\t\tpublic function addImport(pkg:String):void\n\t\t{\n\t\t\tif (imports.indexOf(pkg) < 0)\n\t\t\t{\n\t\t\t\timports.push(pkg);\n\t\t\t}\n\t\t}\n\t\tpublic function addExtraImport(pkg:String):void\n\t\t{\n\t\t\tif (importExtras.indexOf(pkg) < 0)\n\t\t\t{\n\t\t\t\timportExtras.push(pkg);\n\t\t\t}\n\t\t}\n\t\tpublic function findParents(classes:Vector.<AS3Class>):void\n\t\t{\n\t\t\tif (!parent)\n\t\t\t{\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfor (var i in classes)\n\t\t\t{\n\t\t\t\t//Only gather vars from the parent\n\t\t\t\tif (classes[i] != this && parent == classes[i].className)\n\t\t\t\t{\n\t\t\t\t\tparentDefinition = classes[i]; //Found our parent\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tpublic function checkMembersWithAssignments():void\n\t\t{\n\t\t\tvar i:int;\n\t\t\tvar j:*;\n\t\t\tvar classMember:AS3Member;\n\t\t\t// If the type of this param is a Class\n\t\t\tfor (i = 0; i < membersWithAssignments.length; i++)\n\t\t\t{\n\t\t\t\tclassMember = membersWithAssignments[i];\n\t\t\t\t// Make a dumb attempt to identify use of the class as assignments here\n\t\t\t\tfor (j in imports)\n\t\t\t\t{\n\t\t\t\t\tif (packageMap[imports[j]] && classMember.value.indexOf(packageMap[imports[j]].className) >= 0 && parentDefinition !== packageMap[imports[j]])\n\t\t\t\t\t{\n\t\t\t\t\t\t// If this is a token that matches a class from an import statement, store it in the filtered classMap\n\t\t\t\t\t\tclassMapFiltered[packageMap[imports[j]].className] = packageMap[imports[j]];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tpublic function stringifyFunc(fn:AS3Member):String\n\t\t{\n\t\t\tvar buffer:String = \"\";\n\t\t\tif (fn instanceof AS3Function)\n\t\t\t{\n\t\t\t\t//Functions need to be handled differently\n\t\t\t\t//Prepend sub-type if it exists\n\t\t\t\tif (fn.subType)\n\t\t\t\t{\n\t\t\t\t\tbuffer += fn.subType + '_';\n\t\t\t\t}\n\t\t\t\t//Print out the rest of the name and start the function definition\n\t\t\t\tbuffer += fn.name\n\t\t\t\tbuffer += \" = function(\";\n\t\t\t\t//Concat all of the arguments together\n\t\t\t\ttmpArr = [];\n\t\t\t\tfor (j = 0; j < fn.argList.length; j++)\n\t\t\t\t{\n\t\t\t\t\tif (!fn.argList[j].isRestParam)\n\t\t\t\t\t{\n\t\t\t\t\t\ttmpArr.push(fn.argList[j].name);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbuffer += tmpArr.join(\", \") + \") \";\n\t\t\t\t//Function definition is finally added\n\t\t\t\tbuffer += fn.value + \";\\n\";\n\t\t\t} else if (fn instanceof AS3Variable)\n\t\t\t{\n\t\t\t\t//Variables can be added immediately\n\t\t\t\tbuffer += fn.name;\n\t\t\t\tbuffer += \" = \" + fn.value + \";\\n\";\n\t\t\t}\n\t\t\treturn buffer;\n\t\t}\n\t\t\n\t\tpublic function process(classes:Vector.<AS3Class>):void\n\t\t{\n\t\t\tvar self:AS3Class = this;\n\t\t\tvar i:int;\n\t\t\tvar index:int;\n\t\t\tvar currParent:AS3Class = this;\n\t\t\tvar allMembers:Vector.<AS3Member> = new Vector.<AS3Member>();\n\t\t\tvar allFuncs:Vector.<AS3Function> = new Vector.<AS3Function>();\n\t\t\tvar allStaticMembers:Vector.<AS3Member> = new Vector.<AS3Member>();\n\t\t\tvar allStaticFuncs:Vector.<AS3Function> = new Vector.<AS3Function>();\n\n\t\t\twhile (currParent)\n\t\t\t{\n\t\t\t\t//Parse members of this parent\n\t\t\t\tfor (i in currParent.setters)\n\t\t\t\t{\n\t\t\t\t\tallMembers.push(currParent.setters[i]);\n\t\t\t\t}\n\t\t\t\tfor (i in currParent.staticSetters)\n\t\t\t\t{\n\t\t\t\t\tallStaticMembers.push(currParent.staticSetters[i]);\n\t\t\t\t}\n\t\t\t\tfor (i in currParent.getters)\n\t\t\t\t{\n\t\t\t\t\tallMembers.push(currParent.getters[i]);\n\t\t\t\t}\n\t\t\t\tfor (i in currParent.staticGetters)\n\t\t\t\t{\n\t\t\t\t\tallStaticMembers.push(currParent.staticGetters[i]);\n\t\t\t\t}\n\t\t\t\tfor (i in currParent.members)\n\t\t\t\t{\n\t\t\t\t\tallMembers.push(currParent.members[i]);\n\t\t\t\t}\n\t\t\t\tfor (i in currParent.staticMembers)\n\t\t\t\t{\n\t\t\t\t\tallStaticMembers.push(currParent.staticMembers[i]);\n\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t//Go to the next parent\n\t\t\t\tcurrParent = currParent.parentDefinition;\n\t\t\t}\n\t\t\t\n\t\t\t//Add copies of the setters and getters to the \"all\" arrays (for convenience)\n\t\t\tfor (i in setters)\n\t\t\t{\n\t\t\t\tif (setters[i] instanceof AS3Function)\n\t\t\t\t{\n\t\t\t\t\tallFuncs.push(setters[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (i in staticSetters)\n\t\t\t{\n\t\t\t\tif (staticSetters[i] instanceof AS3Function)\n\t\t\t\t{\n\t\t\t\t\tallStaticFuncs.push(staticSetters[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (i in getters)\n\t\t\t{\n\t\t\t\tif (getters[i] instanceof AS3Function)\n\t\t\t\t{\n\t\t\t\t\tallFuncs.push(getters[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (i in staticGetters)\n\t\t\t{\n\t\t\t\tif (staticGetters[i] instanceof AS3Function)\n\t\t\t\t{\n\t\t\t\t\tallStaticFuncs.push(staticGetters[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (i in members)\n\t\t\t{\n\t\t\t\tif (members[i] instanceof AS3Function)\n\t\t\t\t{\n\t\t\t\t\tallFuncs.push(members[i]);\n\t\t\t\t}\n\t\t\t\tif (members[i] instanceof AS3Variable)\n\t\t\t\t{\n\t\t\t\t\t// Fix any obvious assignments that rely on implicit static class name (only works for simple statements)\n\t\t\t\t\tif (members[i].value && retrieveField(members[i].value.replace(/^([a-zA-Z_$][0-9a-zA-Z_$]*)(.*?)$/g, \"$1\"), true))\n\t\t\t\t\t{\n\t\t\t\t\t\tmembers[i].value = className + '.' + members[i].value;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (i in staticMembers)\n\t\t\t{\n\t\t\t\tif (staticMembers[i] instanceof AS3Function)\n\t\t\t\t{\n\t\t\t\t\tallStaticFuncs.push(staticMembers[i]);\n\t\t\t\t}\n\t\t\t\tif (staticMembers[i] instanceof AS3Variable)\n\t\t\t\t{\n\t\t\t\t\t// Fix any obvious assignments that rely on implicit static class name (only works for simple statements)\n\t\t\t\t\tif (staticMembers[i].value && retrieveField(staticMembers[i].value.replace(/^([a-zA-Z_$][0-9a-zA-Z_$]*)(.*?)$/g, \"$1\"), true))\n\t\t\t\t\t{\n\t\t\t\t\t\tstaticMembers[i].value = className + '.' + staticMembers[i].value;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Insert $init function for instantiations\n\t\t\tfor (i in allFuncs)\n\t\t\t{\n\t\t\t\tMain.debug(\"Now parsing function: \" + className + \":\" + allFuncs[i].name);\n\t\t\t\tallFuncs[i].value = AS3Parser.parseFunc(this, allFuncs[i].value, allFuncs[i].buildLocalVariableStack(), allFuncs[i].isStatic)[0];\n\t\t\t\tallFuncs[i].value = AS3Parser.checkArguments(allFuncs[i]);\n\t\t\t\tif (allFuncs[i].name === \"$init\")\n\t\t\t\t{\n\t\t\t\t\t//Inject instantiations here\n\t\t\t\t\tallFuncs[i].value = AS3Parser.injectInstantiations(this, allFuncs[i]);\n\t\t\t\t}\n\t\t\t\tif (allFuncs[i].name === className)\n\t\t\t\t{\n\t\t\t\t\t//Inject $init() into constructor\n\t\t\t\t\tallFuncs[i].value = AS3Parser.injectInit(this, allFuncs[i]);\n\t\t\t\t}\n\t\t\t\tallFuncs[i].value = AS3Parser.cleanup(allFuncs[i].value);\n\t\t\t\t//Fix supers\n\t\t\t\tallFuncs[i].value = allFuncs[i].value.replace(/super\\.(.*?)\\(/g, parent + '.prototype.$1.call(this, ').replace(/\\.call\\(this,\\s*\\)/g, \".call(this)\");\n\t\t\t\tallFuncs[i].value = allFuncs[i].value.replace(/super\\(/g, parent + '.call(this, ').replace(/\\.call\\(this,\\s*\\)/g, \".call(this)\");\n\t\t\t\tallFuncs[i].value = allFuncs[i].value.replace(new RegExp(\"this[.]\" + parent, \"g\"), parent); //Fix extra 'this' on the parent\n\t\t\t}\n\t\t\t\n\t\t\tfor (i in allStaticFuncs)\n\t\t\t{\n\t\t\t\tMain.debug(\"Now parsing static function: \" + className + \":\" + allStaticFuncs[i].name);\n\t\t\t\tallStaticFuncs[i].value = AS3Parser.parseFunc(this, allStaticFuncs[i].value, allStaticFuncs[i].buildLocalVariableStack(), allStaticFuncs[i].isStatic)[0];\n\t\t\t\tallStaticFuncs[i].value = AS3Parser.checkArguments(allStaticFuncs[i]);\n\t\t\t\tallStaticFuncs[i].value = AS3Parser.cleanup(allStaticFuncs[i].value);\n\t\t\t}\n\t\t}\n\t\tpublic function toString():String\n\t\t{\n\t\t\t//Outputs the class inside a JS function\n\t\t\tvar i:*;\n\t\t\tvar j:*;\n\t\t\tvar buffer:String = \"\";\n\n\t\t\tif (requires.length > 0)\n\t\t\t{\n\t\t\t\tif (safeRequire)\n\t\t\t\t{\n\t\t\t\t\tfor (i in requires)\n\t\t\t\t\t{\n\t\t\t\t\t\tbuffer += 'var ' + requires[i].substring(1, requires[i].length-1) + ' = (function () { try { return require(' + requires[i] + '); } catch(e) { return undefined; }})();\\n';\n\t\t\t\t\t}\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tfor (i in requires)\n\t\t\t\t\t{\n\t\t\t\t\t\tbuffer += 'var ' + requires[i].substring(1, requires[i].length-1) + ' = require(' + requires[i] + ');\\n';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbuffer += \"\\n\";\n\t\t\t}\n\t\t\n\t\t\tvar tmpArr:Array = null;\n\n\t\t\t//Parent class must be imported if it exists\n\t\t\tif (parentDefinition)\n\t\t\t{\n\t\t\t\tbuffer += \"var \" + parentDefinition.className + \" = module.import('\" + parentDefinition.packageName + \"', '\" + parentDefinition.className + \"');\\n\";\n\t\t\t}\n\n\t\t\t//Create refs for all the other classes\n\t\t\tif (imports.length > 0)\n\t\t\t{\n\t\t\t\ttmpArr = [];\n\t\t\t\tfor (i in imports)\n\t\t\t\t{\n\t\t\t\t\tif (!(ignoreFlash && imports[i].indexOf('flash.') >= 0) && parent != imports[i].substr(imports[i].lastIndexOf('.') + 1) && packageName + '.' + className != imports[i]) //Ignore flash imports\n\t\t\t\t\t{\n\t\t\t\t\t\t// Must be in the filtered map, otherwise no point in writing\n\t\t\t\t\t\tif (!packageMap[imports[i]])\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tMain.warn(\"Warning, missing class path: \" + imports[i] + \" (found in \" + packageName + '.' + className + \")\");\n\t\t\t\t\t\t} else if (classMapFiltered[packageMap[imports[i]].className])\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttmpArr.push(imports[i].substr(imports[i].lastIndexOf('.') + 1)); //<-This will return characters after the final '.', or the entire String if no '.'\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t//Join up separated by commas\n\t\t\t\tif (tmpArr.length > 0)\n\t\t\t\t{\n\t\t\t\t\tbuffer += 'var ';\n\t\t\t\t\tbuffer += tmpArr.join(\", \") + \";\\n\";\n\t\t\t\t}\n\t\t\t}\n\t\t\t//Check for injection function code\n\t\t\tvar injectedText = \"\";\n\t\t\tfor (i in imports)\n\t\t\t{\n\t\t\t\tif (!(ignoreFlash && imports[i].indexOf('flash.') >= 0) && packageName + '.' + className != imports[i] && !(parentDefinition && parentDefinition.packageName + '.' + parentDefinition.className == imports[i])) //Ignore flash imports and parent for injections\n\t\t\t\t{\n\t\t\t\t\t// Must be in the filtered map, otherwise no point in writing\n\t\t\t\t\tif (!packageMap[imports[i]])\n\t\t\t\t\t{\n\t\t\t\t\t\tMain.warn(\"Warning, missing class path: \" + imports[i] + \" (found in \" + packageName + '.' + className + \")\");\n\t\t\t\t\t} else if (classMapFiltered[packageMap[imports[i]].className])\n\t\t\t\t\t{\n\t\t\t\t\t\tinjectedText += \"\\t\" + imports[i].substr(imports[i].lastIndexOf('.') + 1) + \" = module.import('\" + packageMap[imports[i]].packageName + \"', '\" + packageMap[imports[i]].className + \"');\\n\";\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (injectedText.length > 0)\n\t\t\t{\n\t\t\t\tbuffer += \"module.inject = function () {\\n\";\n\t\t\t\tbuffer += injectedText;\n\t\t\t\tbuffer += \"};\\n\";\n\t\t\t}\n\t\t\t\n\t\t\tbuffer += '\\n';\n\t\t\t\n\t\t\tbuffer += (fieldMap[className]) ? \"var \" + stringifyFunc(fieldMap[className]) : \"var \" + className + \" = function \" + className + \"() {};\";\n\t\t\t\n\t\t\tbuffer += '\\n';\n\t\t\tbuffer += '\\n';\n\t\t\t\n\t\t\tif (parent)\n\t\t\t{\n\t\t\t\t//Extend parent if necessary\n\t\t\t\tbuffer += className + \".prototype = Object.create(\" + parent + \".prototype);\";\n\t\t\t}\n\t\t\t\n\t\t\tbuffer += '\\n\\n';\n\t\t\t\n\t\t\t// Deal with static member assigments\n\t\t\tif (staticMembers.length > 0)\n\t\t\t{\n\t\t\t\t//Place defaults first\n\t\t\t\tfor (i in staticMembers)\n\t\t\t\t{\n\t\t\t\t\tif (staticMembers[i] instanceof AS3Function)\n\t\t\t\t\t{\n\t\t\t\t\t\tbuffer += className + \".\" + stringifyFunc(staticMembers[i]);\n\t\t\t\t\t} else if (staticMembers[i].type === \"Number\" || staticMembers[i].type === \"int\" || staticMembers[i].type === \"uint\")\n\t\t\t\t\t{\n\t\t\t\t\t\tif (isNaN(parseInt(staticMembers[i].value)))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tbuffer += className + \".\" + staticMembers[i].name + ' = 0;\\n';\n\t\t\t\t\t\t} else\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tbuffer += className + \".\" + stringifyFunc(staticMembers[i]);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (staticMembers[i].type === \"Boolean\")\n\t\t\t\t\t{\n\t\t\t\t\t\tbuffer += className + \".\" + staticMembers[i].name + ' = false;\\n';\n\t\t\t\t\t} else\n\t\t\t\t\t{\n\t\t\t\t\t\tbuffer += className + \".\" +  staticMembers[i].name + ' = null;\\n';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (i in staticGetters)\n\t\t\t\t{\n\t\t\t\t\tbuffer += className + \".\" + stringifyFunc(staticGetters[i]);\n\t\t\t\t}\n\t\t\t\tfor (i in staticSetters)\n\t\t\t\t{\n\t\t\t\t\tbuffer += className + \".\" + stringifyFunc(staticSetters[i]);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tbuffer += '\\n';\n\t\t\t\t\n\t\t\t\tbuffer += className + \".$cinit = function () {\\n\";\n\t\t\t\t\n\t\t\t\t// Now do the assignments for the rest\n\t\t\t\tfor (i in staticMembers)\n\t\t\t\t{\n\t\t\t\t\tif (!(staticMembers[i] instanceof AS3Function))\n\t\t\t\t\t{\n\t\t\t\t\t\tbuffer += \"\\t\" + AS3Parser.cleanup( className + '.' + staticMembers[i].name + ' = ' + staticMembers[i].value + \";\\n\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tbuffer += '\\n';\n\t\t\t\tbuffer += \"};\\n\";\n\t\t\t}\t\t\n\t\t\tbuffer += \"\\n\";\n\t\t\t\n\t\t\tfor (i in getters)\n\t\t\t{\n\t\t\t\tbuffer += className + \".prototype.\" + stringifyFunc(getters[i]);\n\t\t\t}\n\t\t\tfor (i in setters)\n\t\t\t{\n\t\t\t\tbuffer += className + \".prototype.\" + stringifyFunc(setters[i]);\n\t\t\t}\n\t\t\tfor (i in members)\n\t\t\t{\n\t\t\t\tif (members[i].name === className)\n\t\t\t\t{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (members[i] instanceof AS3Function || (AS3Class.nativeTypes.indexOf(members[i].type) >= 0 && members[i].value))\n\t\t\t\t{\n\t\t\t\t\tbuffer += className + \".prototype.\" + stringifyFunc(members[i]); //Print functions immediately\n\t\t\t\t} else if (members[i].type === \"Number\" || members[i].type === \"int\" || members[i].type === \"uint\")\n\t\t\t\t{\n\t\t\t\t\tif (isNaN(parseInt(members[i].value)))\n\t\t\t\t\t{\n\t\t\t\t\t\tbuffer += className + \".prototype.\" + members[i].name + ' = 0;\\n';\n\t\t\t\t\t} else\n\t\t\t\t\t{\n\t\t\t\t\t\tbuffer += className + \".prototype.\" + stringifyFunc(members[i]);\n\t\t\t\t\t}\n\t\t\t\t} else if (members[i].type === \"Boolean\")\n\t\t\t\t{\n\t\t\t\t\tbuffer += className + \".prototype.\" + members[i].name + ' = false;\\n';\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tbuffer += className + \".prototype.\" + members[i].name + ' = null;\\n';\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbuffer = buffer.substr(0, buffer.length - 2) + \"\\n\"; //Strips the final comma out of the string\n\n\t\t\tbuffer += \"\\n\\n\";\n\t\t\tbuffer += \"module.exports = \" + className + \";\\n\";\n\n\t\t\t//Remaining fixes\n\t\t\tbuffer = buffer.replace(/(this\\.)+/g, \"this.\");\n\n\t\t\treturn buffer;\n\t\t}\n\t}\n}"
  },
  {
    "path": "src/com/mcleodgaming/as3js/parser/AS3Parser.as",
    "content": "package com.mcleodgaming.as3js.parser\n{\n\timport com.mcleodgaming.as3js.Main;\n\timport com.mcleodgaming.as3js.enums.*;\n\timport com.mcleodgaming.as3js.types.*;\n\trequire \"path\"\n\trequire \"fs\"\n\t\n\tpublic class AS3Parser \n\t{\n\t\t/**\n\t\t * Keeps track of previous function name to assist extractBlock() debugging\n\t\t * TODO: This could definitely be implemented better\n\t\t */\n\t\tpublic static var PREVIOUS_BLOCK:String;\n\t\t\n\t\t//public var index:int;\n\t\tpublic var stack:Array;\n\t\tpublic var src:String;\n\t\tpublic var classPath:String;\n\t\tpublic var parserOptions:Object;\n\t\t\t\n\t\tpublic function AS3Parser(src:String, classPath:String = null):void \n\t\t{\n\t\t\t//index = 0;\n\t\t\tstack = [];\n\t\t\tthis.src = src;\n\t\t\tthis.classPath = classPath;\n\t\t\tparserOptions = { };\n\t\t\tparserOptions.safeRequire = false;\n\t\t\tparserOptions.ignoreFlash = false;\n\t\t}\n\t\t\n\t\tpublic static function increaseIndent(str:String, indent:String):String\n\t\t{\n\t\t\treturn (indent + str).replace(/\\n/g, \"\\n\" + indent);\n\t\t}\n\t\tpublic static function parseArguments(str:String):Array\n\t\t{\n\t\t\tvar args:Vector.<AS3Argument> = new Vector.<AS3Argument>();\n\t\t\tvar tmpToken:AS3Token;\n\t\t\tvar tmpArr:Array = AS3Parser.extractBlock(str, 0, '(', ')');\n\t\t\tvar tmpExtractArr:Array = null;\n\t\t\tvar index:int = tmpArr[1] - 1; //Ending index of parsed block\n\t\t\tvar tmpStr:String = tmpArr[0].trim(); //Parsed block\n\t\t\ttmpStr = tmpStr.substr(1, tmpStr.length - 2); //Remove outer parentheses\n\t\t\ttmpArr = null; //Trash this\n\t\t\ttmpArr = tmpStr.split(','); //Split args by commas\n\t\t\t//Don't bother if there are no arguments\n\t\t\tif (tmpArr.length > 0 && tmpArr[0] != '')\n\t\t\t{\n\t\t\t\t//Truncate spaces and assign values to arguments as needed\n\t\t\t\tfor (var i = 0; i < tmpArr.length; i++)\n\t\t\t\t{\n\t\t\t\t\ttmpStr = tmpArr[i].trim();\n\t\t\t\t\targs.push(new AS3Argument());\n\t\t\t\t\tif (tmpStr.indexOf('...') === 0)\n\t\t\t\t\t{\n\t\t\t\t\t\t//This is a ...rest argument, stop here\n\t\t\t\t\t\targs[args.length-1].name = tmpStr.substr(3);\n\t\t\t\t\t\targs[args.length-1].isRestParam = true;\n\t\t\t\t\t\tMain.debug('----->Parsed a ...rest param: ' + args[args.length-1].name);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} else\n\t\t\t\t\t{\n\t\t\t\t\t\t//Grab the function name\n\t\t\t\t\t\ttmpToken = AS3Parser.nextWord(tmpStr, 0, AS3Pattern.VARIABLE[0], AS3Pattern.VARIABLE[1]); //Parse out the function name\n\t\t\t\t\t\targs[args.length-1].name = tmpToken.token; //Set the argument name\n\t\t\t\t\t\tMain.debug('----->Sub-Function argument found: ' + tmpToken.token);\n\t\t\t\t\t\t//If a colon was next, we'll assume it was typed and grab it\n\t\t\t\t\t\tif (tmpToken.index < tmpStr.length && tmpStr.charAt(tmpToken.index) == ':')\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttmpToken = AS3Parser.nextWord(tmpStr, tmpToken.index, AS3Pattern.VARIABLE_TYPE[0], AS3Pattern.VARIABLE_TYPE[1]); //Parse out the argument type\n\t\t\t\t\t\t\targs[args.length-1].type = tmpToken.token; //Set the argument type\n\t\t\t\t\t\t\tMain.debug('----->Sub-Function argument typed to: ' + tmpToken.token);\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttmpToken = AS3Parser.nextWord(tmpStr, tmpToken.index, AS3Pattern.ASSIGN_START[0], AS3Pattern.ASSIGN_START[1]);\n\t\t\t\t\t\tif (tmpToken.token == \"=\")\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t//Use all characters after self symbol to set value\n\t\t\t\t\t\t\ttmpExtractArr = AS3Parser.extractUpTo(tmpStr, tmpToken.index, /[;\\r\\n]/g);\n\t\t\t\t\t\t\t//Store value\n\t\t\t\t\t\t\targs[args.length-1].value =  tmpExtractArr[0].trim();\n\t\t\t\t\t\t\t//Store value\n\t\t\t\t\t\t\tMain.debug('----->Sub-Function argument defaulted to: ' + tmpExtractArr[0].trim());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn args;\n\t\t}\n\t\tpublic static function checkForCommentOpen(str:String):String\n\t\t{\n\t\t\treturn (str == \"//\") ? AS3ParseState.COMMENT_INLINE : (str == \"/*\") ? AS3ParseState.COMMENT_MULTILINE : null;\n\t\t}\n\t\tpublic static function checkForCommentClose(state, str):Boolean\n\t\t{\n\t\t\treturn (state == AS3ParseState.COMMENT_INLINE && (str.charAt(0) == '\\n' || str.charAt(0) == '\\r' || str.charAt(0) == '')) ? true : (state == AS3ParseState.COMMENT_MULTILINE && str == \"*/\") ? true : false; \n\t\t}\n\t\tpublic static function checkForStringOpen(str:String):String\n\t\t{\n\t\t\treturn (str == '\"') ? AS3ParseState.STRING_DOUBLE_QUOTE : (str == \"'\") ? AS3ParseState.STRING_SINGLE_QUOTE : null;\n\t\t}\n\t\tpublic static function checkForStringClose(state, str):Boolean\n\t\t{\n\t\t\treturn (state == AS3ParseState.STRING_DOUBLE_QUOTE && str == '\"') ? true : (state == AS3ParseState.STRING_SINGLE_QUOTE && str == \"'\") ? true : false; \n\t\t}\n\t\tpublic static function nextWord(src:String, index:int, characters:String, pattern:String):AS3Token\n\t\t{\n\t\t\tcharacters = characters || AS3Pattern.IDENTIFIER[0];\n\t\t\tpattern = pattern || AS3Pattern.IDENTIFIER[1];\n\t\t\tvar tokenBuffer:String = null;\n\t\t\tvar extraBuffer:String = ''; //Contains characters that were missed\n\t\t\tvar escapeToggle:Boolean = false;\n\t\t\tvar innerState:String = null;\n\t\t\tfor (; index < src.length; index++)\n\t\t\t{\n\t\t\t\tvar c = src.charAt(index);\n\t\t\t\tif (c.match(characters))\n\t\t\t\t{\n\t\t\t\t\ttokenBuffer = (tokenBuffer) ? tokenBuffer + c : c; //Create new token buffer if needed, otherwise append\n\t\t\t\t} else if (!innerState && AS3Parser.checkForCommentOpen(src.substr(index, 2)) && !tokenBuffer)\n\t\t\t\t{\n\t\t\t\t\ttokenBuffer = null;\n\t\t\t\t\tMain.debug(\"Entering comment...\");\n\t\t\t\t\tinnerState = AS3Parser.checkForCommentOpen(src.substr(index, 2));\n\t\t\t\t\textraBuffer += src.substr(index, 2);\n\t\t\t\t\tindex += 2; //Skip next index\n\t\t\t\t\t//Loop until we break out of comment\n\t\t\t\t\tfor (; index < src.length; index++)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (AS3Parser.checkForCommentClose(innerState, src.substr(index, 2)))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (innerState == AS3ParseState.COMMENT_MULTILINE)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\textraBuffer += src.substr(index, 2);\n\t\t\t\t\t\t\t\tindex++; //Skip next token\n\t\t\t\t\t\t\t} else\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\textraBuffer += src.charAt(index);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tinnerState = null; //Return to previous state\n\t\t\t\t\t\t\tMain.debug(\"Exiting comment...\");\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t} else\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\textraBuffer += src.charAt(index);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}  else if (!innerState && AS3Parser.checkForStringOpen(src.charAt(index)) && !tokenBuffer)\n\t\t\t\t{\n\t\t\t\t\ttokenBuffer = null;\n\t\t\t\t\tMain.debug(\"Entering string...\");\n\t\t\t\t\tinnerState = AS3Parser.checkForStringOpen(src.charAt(index));\n\t\t\t\t\textraBuffer += src.substr(index, 1);\n\t\t\t\t\tindex++; //Skip to next index\n\t\t\t\t\t//Loop until we break out of string\n\t\t\t\t\tfor (; index < src.length; index++)\n\t\t\t\t\t{\n\t\t\t\t\t\textraBuffer += src.charAt(index);\n\t\t\t\t\t\tif (!escapeToggle && src.charAt(index) == '\\\\')\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tescapeToggle = true;\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tescapeToggle = false;\n\t\t\t\t\t\tif (AS3Parser.checkForStringClose(innerState, src.charAt(index)))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tinnerState = null; //Return to previous state\n\t\t\t\t\t\t\tMain.debug(\"Exiting string...\");\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (tokenBuffer && tokenBuffer.match(pattern))\n\t\t\t\t{\n\t\t\t\t\treturn new AS3Token(tokenBuffer, index, extraBuffer); //[Token, Index]\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tif (tokenBuffer)\n\t\t\t\t\t{\n\t\t\t\t\t\textraBuffer += tokenBuffer + c;\n\t\t\t\t\t} else \n\t\t\t\t\t{\n\t\t\t\t\t\textraBuffer += c;\n\t\t\t\t\t}\n\t\t\t\t\ttokenBuffer = null;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn new AS3Token(tokenBuffer || null, index, extraBuffer); //[Token, Index]\n\t\t}\n\t\tpublic static function extractBlock(text:String, start:int = 0, opening:String = \"{\", closing:String = \"}\"):Array\n\t\t{\n\t\t\tvar buffer:String = \"\";\n\t\t\tvar i:int = start;\n\t\t\tvar count:int = 0;\n\t\t\tvar started:Boolean = false;\n\t\t\tvar insideString:String = null;\n\t\t\tvar insideComment:String = null;\n\t\t\tvar escapingChar:Boolean = false;\n\t\t\twhile (!(count == 0 && started) && i < text.length)\n\t\t\t{\n\t\t\t\tif (insideComment)\n\t\t\t\t{\n\t\t\t\t\t//Inside of a comment, wait until we get out\n\t\t\t\t\tif (insideComment == '//' && (text.charAt(i) == '\\n' || text.charAt(i) == '\\r'))\n\t\t\t\t\t{\n\t\t\t\t\t\tinsideComment = null; //End inline comment\n\t\t\t\t\t\tMain.debug(\"Exited comment\");\n\t\t\t\t\t} else if (insideComment == '/*' && text.charAt(i) == '*' && i + 1 < text.length && text.charAt(i + 1) == '/')\n\t\t\t\t\t{\n\t\t\t\t\t\tinsideComment = null; //End multiline comment\n\t\t\t\t\t\tMain.debug(\"Exited comment\");\n\t\t\t\t\t}\n\t\t\t\t} else if (insideString)\n\t\t\t\t{\n\t\t\t\t\t//Inside of a string, wait until we get out\n\t\t\t\t\tif (!escapingChar && text.charAt(i) == \"\\\\\")\n\t\t\t\t\t{\n\t\t\t\t\t\tescapingChar = true; //Start escape sequence\n\t\t\t\t\t} else if (!escapingChar && text.charAt(i) == insideString)\n\t\t\t\t\t{\n\t\t\t\t\t\tinsideString = null; //Found closing quote\n\t\t\t\t\t} else\n\t\t\t\t\t{\n\t\t\t\t\t\tescapingChar = false; //Forget escape sequence\n\t\t\t\t\t}\n\t\t\t\t} else if (text.charAt(i) == opening)\n\t\t\t\t{\n\t\t\t\t\tstarted = true;\n\t\t\t\t\tcount++; //Found opening\n\t\t\t\t} else if (text.charAt(i) == closing)\n\t\t\t\t{\n\t\t\t\t\tcount--; //Found closing\n\t\t\t\t} else if ((text.charAt(i) == '\\\"' || text.charAt(i) == '\\''))\n\t\t\t\t{\n\t\t\t\t\tinsideString = text.charAt(i); //Now inside of a string\n\t\t\t\t} else if (text.charAt(i) == '/' && i + 1 < text.length && text.charAt(i + 1) == '/')\n\t\t\t\t{\n\t\t\t\t\tMain.debug(\"Entering comment... \" + \"(//)\");\n\t\t\t\t\tinsideComment = '//';\n\t\t\t\t} else if (text.charAt(i) == '/' && i + 1 < text.length && text.charAt(i + 1) == '*')\n\t\t\t\t{\n\t\t\t\t\tMain.debug(\"Entering comment...\" + \"(/*)\");\n\t\t\t\t\tinsideComment = '/*';\n\t\t\t\t}\n\t\t\t\tif (started)\n\t\t\t\t{\n\t\t\t\t\tbuffer += text.charAt(i);\n\t\t\t\t}\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tif (!started)\n\t\t\t{\n\t\t\t\tthrow new Error(\"Error, no starting '\" + opening  + \"' found for method body while parsing \" + AS3Parser.PREVIOUS_BLOCK);\n\t\t\t} else if (count > 0)\n\t\t\t{\n\t\t\t\tthrow new Error(\"Error, no closing '\" + closing  + \"' found for method body while parsing \" + AS3Parser.PREVIOUS_BLOCK);\n\t\t\t} else if (count < 0)\n\t\t\t{\n\t\t\t\tthrow new Error(\"Error, malformed enclosing '\" + opening + closing + \" body while parsing \" + AS3Parser.PREVIOUS_BLOCK);\n\t\t\t}\n\t\t\treturn [buffer, i];\n\t\t}\n\t\tpublic static function extractUpTo(text:String, start:int, target:String):Array\n\t\t{\n\t\t\tvar buffer:String = \"\";\n\t\t\tvar i:int = start;\n\t\t\tvar insideString:String = null;\n\t\t\tvar insideComment:String = null;\n\t\t\tvar escapingChar:Boolean = false;\n\t\t\tvar pattern:String = new RegExp(target);\n\t\t\twhile (i < text.length)\n\t\t\t{\n\t\t\t\tif (insideComment)\n\t\t\t\t{\n\t\t\t\t\t//Inside of a comment, wait until we get out\n\t\t\t\t\tif (insideComment == '//' && (text.charAt(i) == '\\n' || text.charAt(i) == '\\r'))\n\t\t\t\t\t{\n\t\t\t\t\t\tinsideComment = null; //End inline comment\n\t\t\t\t\t\tMain.debug(\"Exited comment\");\n\t\t\t\t\t} else if (insideComment == '/*' && text.charAt(i) == '*' && i + 1 < text.length && text.charAt(i + 1) == '/')\n\t\t\t\t\t{\n\t\t\t\t\t\tinsideComment = null; //End multiline comment\n\t\t\t\t\t\tMain.debug(\"Exited comment\");\n\t\t\t\t\t}\n\t\t\t\t} else if (insideString)\n\t\t\t\t{\n\t\t\t\t\t//Inside of a string, wait until we get out\n\t\t\t\t\tif (!escapingChar && text.charAt(i) == \"\\\\\")\n\t\t\t\t\t{\n\t\t\t\t\t\tescapingChar = true; //Start escape sequence\n\t\t\t\t\t} else if (!escapingChar && text.charAt(i) == insideString)\n\t\t\t\t\t{\n\t\t\t\t\t\tinsideString = null; //Found closing quote\n\t\t\t\t\t} else\n\t\t\t\t\t{\n\t\t\t\t\t\tescapingChar = false; //Forget escape sequence\n\t\t\t\t\t}\n\t\t\t\t} else if ((text.charAt(i) == '\\\"' || text.charAt(i) == '\\''))\n\t\t\t\t{\n\t\t\t\t\tinsideString = text.charAt(i); //Now inside of a string\n\t\t\t\t} else if (text.charAt(i) == '/' && i + 1 < text.length && text.charAt(i + 1) == '/')\n\t\t\t\t{\n\t\t\t\t\tMain.debug(\"Entering comment... \" + \"(//)\");\n\t\t\t\t\tinsideComment = '//';\n\t\t\t\t} else if (text.charAt(i) == '/' && i + 1 < text.length && text.charAt(i + 1) == '*')\n\t\t\t\t{\n\t\t\t\t\tMain.debug(\"Entering comment...\" + \"(/*)\");\n\t\t\t\t\tinsideComment = '/*';\n\t\t\t\t} else if (text.charAt(i).match(pattern))\n\t\t\t\t{\n\t\t\t\t\tbreak; //Done\n\t\t\t\t}\n\t\t\t\tbuffer += text.charAt(i);\n\t\t\t\ti++;\n\t\t\t}\n\t\t\treturn [buffer, i];\n\t\t}\n\t\t\n\t\tpublic static function fixClassPath(clsPath:String):String\n\t\t{\n\t\t\t// Class paths at the root level might accidentally be prepended with a \".\"\n\t\t\treturn clsPath.replace(/^\\./g, \"\");\n\t\t}\n\t\tpublic function getState():String\n\t\t{\n\t\t\treturn (this.stack.length > 0) ? this.stack[this.stack.length - 1] : null;\n\t\t}\n\t\tprivate function parseHelper(cls:AS3Class, src:String):void\n\t\t{\n\t\t\tvar i:*;\n\t\t\tvar j:*;\n\t\t\tvar c:String;\n\t\t\tvar currToken:AS3Token = null;\n\t\t\tvar tmpToken:AS3Token = null;\n\t\t\tvar tmpStr:String = null;\n\t\t\tvar tmpArr:Array = null;\n\t\t\tvar currMember:AS3Member = null;\n\t\t\tvar index:int;\n\t\t\tfor (index = 0; index < src.length; index++)\n\t\t\t{\n\t\t\t\tc = src.charAt(index);\n\t\t\t\tif (getState() == AS3ParseState.START)\n\t\t\t\t{\n\t\t\t\t\t//String together letters only until we reach a non-letter\n\t\t\t\t\tcurrToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]);\n\t\t\t\t\tindex = currToken.index - 1; //Update to the new position\n\t\t\t\t\tif (currToken.token == 'package')\n\t\t\t\t\t{\n\t\t\t\t\t\tstack.push(AS3ParseState.PACKAGE_NAME);\n\t\t\t\t\t}\n\t\t\t\t} else if (getState() == AS3ParseState.PACKAGE_NAME)\n\t\t\t\t{\n\t\t\t\t\tcurrToken = AS3Parser.nextWord(src, index, AS3Pattern.OBJECT[0], AS3Pattern.OBJECT[1]); //Package name\n\t\t\t\t\ttmpToken = AS3Parser.nextWord(src, index, AS3Pattern.CURLY_BRACE[0], AS3Pattern.CURLY_BRACE[1]); //Upcoming curly brace\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tindex = currToken.index - 1;\n\t\t\t\t\tif (!currToken.token || !tmpToken.token)\n\t\t\t\t\t{\n\t\t\t\t\t\tthrow new Error(\"Error parsing package name.\");\n\t\t\t\t\t} else\n\t\t\t\t\t{\n\t\t\t\t\t\tif (tmpToken.index < currToken.index)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcls.packageName = ''; //Curly brace came before next token\n\t\t\t\t\t\t\tindex = tmpToken.index;\n\t\t\t\t\t\t} else\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcls.packageName = currToken.token; //Just grab the package name\n\t\t\t\t\t\t}\n\t\t\t\t\t\tMain.debug('Found package: ' + cls.packageName);\n\t\t\t\t\t\tcls.importWildcards.push(AS3Parser.fixClassPath(cls.packageName + '.*')); //Add wild card for its own folder\n\t\t\t\t\t\tstack.push(AS3ParseState.PACKAGE);\n\t\t\t\t\t\tMain.debug('Attempting to parse package...');\n\t\t\t\t\t}\n\t\t\t\t} else if (getState() == AS3ParseState.PACKAGE)\n\t\t\t\t{\n\t\t\t\t\tcurrToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]);\n\t\t\t\t\tindex = currToken.index - 1;\n\t\t\t\t\tif (currToken.token == 'class' || currToken.token == 'interface')\n\t\t\t\t\t{\n\t\t\t\t\t\tif(currToken.token == 'interface')\n\t\t\t\t\t\t\tcls.isInterface = true;\n\t\t\t\t\t\tstack.push(AS3ParseState.CLASS_NAME);\n\t\t\t\t\t\tMain.debug('Found class keyword...');\n\t\t\t\t\t} else if (currToken.token == 'import')\n\t\t\t\t\t{\n\t\t\t\t\t\tstack.push(AS3ParseState.IMPORT_PACKAGE);\n\t\t\t\t\t\tMain.debug('Found import keyword...');\n\t\t\t\t\t} else if (currToken.token == 'require')\n\t\t\t\t\t{\n\t\t\t\t\t\tstack.push(AS3ParseState.REQUIRE_MODULE);\n\t\t\t\t\t\tMain.debug('Found require keyword...');\n\t\t\t\t\t}\n\t\t\t\t} else if (getState() == AS3ParseState.CLASS_NAME)\n\t\t\t\t{\n\t\t\t\t\tcurrToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]);\n\t\t\t\t\ttmpToken = AS3Parser.nextWord(src, index, AS3Pattern.CURLY_BRACE[0], AS3Pattern.CURLY_BRACE[1]);\n\t\t\t\t\tindex = currToken.index;\n\t\t\t\t\tif (!currToken.token || !tmpToken.token)\n\t\t\t\t\t{\n\t\t\t\t\t\tthrow new Error(\"Error parsing class name.\");\n\t\t\t\t\t} else if (tmpToken.index < currToken.index)\n\t\t\t\t\t{\n\t\t\t\t\t\tthrow new Error(\"Error, no class name found before curly brace.\");\n\t\t\t\t\t} else\n\t\t\t\t\t{\n\t\t\t\t\t\t//Set the class name\n\t\t\t\t\t\tcls.className = currToken.token;\n\t\t\t\t\t\t\n\t\t\t\t\t\t// Update fully qualified class path if needed\n\t\t\t\t\t\tclassPath = classPath || AS3Parser.fixClassPath(cls.packageName + '.' + cls.className); //Remove extra \".\" for top level packages\n\t\t\t\t\t\t\n\t\t\t\t\t\tcls.classMap[cls.className] = cls; //Register self into the import map (used for static detection)\n\t\t\t\t\t\t//Now we will check for parent class and any interfaces\n\t\t\t\t\t\tcurrToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]);\n\t\t\t\t\t\tif (currToken.token == 'extends' && currToken.index < tmpToken.index)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tindex = currToken.index;\n\t\t\t\t\t\t\tcurrToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]);\n\t\t\t\t\t\t\tindex = currToken.index;\n\t\t\t\t\t\t\t//The token following 'extends' must be the parent class\n\t\t\t\t\t\t\tcls.parent = currToken.token;\n\t\t\t\t\t\t\t//Prep the next token\n\t\t\t\t\t\t\tcurrToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]);\n\t\t\t\t\t\t\tMain.debug(\"Found parent: \" + cls.parent);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (currToken.token == 'implements' && currToken.index < tmpToken.index)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tindex = currToken.index;\n\t\t\t\t\t\t\tcurrToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]);\n\t\t\t\t\t\t\tindex = currToken.index;\n\t\t\t\t\t\t\t//The token following 'implements' must be an interface\n\t\t\t\t\t\t\tcls.interfaces.push(currToken.token);\n\t\t\t\t\t\t\tMain.debug(\"Found interface: \" + currToken.token);\n\t\t\t\t\t\t\tcurrToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]);\n\t\t\t\t\t\t\t//While we are at a token before the next curly brace\n\t\t\t\t\t\t\twhile (currToken.index < tmpToken.index && currToken.index < src.length)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t//Consider self token another interface being implemented\n\t\t\t\t\t\t\t\tindex = currToken.index;\n\t\t\t\t\t\t\t\tMain.debug(\"Found interface: \" + currToken.token);\n\t\t\t\t\t\t\t\tcls.interfaces.push(currToken.token);\n\t\t\t\t\t\t\t\tcurrToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]);\n\t\t\t\t\t\t\t\tindex = currToken.index;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tMain.debug('Parsed class name: ' + cls.className);\n\t\t\t\t\t\t//Now parsing inside of the class\n\t\t\t\t\t\tstack.push(AS3ParseState.CLASS);\n\t\t\t\t\t\tMain.debug('Attempting to parse class...');\n\t\t\t\t\t\t\n\t\t\t\t\t\t//Extract out the next method block\n\t\t\t\t\t\tAS3Parser.PREVIOUS_BLOCK = cls.className + \":Class\";\n\t\t\t\t\t\ttmpStr = AS3Parser.extractBlock(src, index)[0];\n\t\t\t\t\t\tindex += tmpStr.length - 1;\n\t\t\t\t\t\t\n\t\t\t\t\t\t//Recursively call parseHelper again under this new state (Once returned, package will be exited)\n\t\t\t\t\t\tparseHelper(cls, tmpStr);\n\t\t\t\t\t}\n\t\t\t\t} else if (getState() == AS3ParseState.CLASS)\n\t\t\t\t{\n\t\t\t\t\tcurrMember = currMember || new AS3Member(); //Declare a new member to work with if it doesn't exist yet\n\t\t\t\t\tcurrToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]);\n\t\t\t\t\tindex = currToken.index - 1;\n\t\t\t\t\tif (currToken.token == AS3Encapsulation.PUBLIC || currToken.token == AS3Encapsulation.PRIVATE || currToken.token == AS3Encapsulation.PROTECTED)\n\t\t\t\t\t{\n\t\t\t\t\t\tcurrMember.encapsulation = currToken.token;\n\t\t\t\t\t\tMain.debug('->Member encapsulation set to ' + currMember.encapsulation);\n\t\t\t\t\t} else if (currToken.token == 'static')\n\t\t\t\t\t{\n\t\t\t\t\t\tcurrMember.isStatic = true;\n\t\t\t\t\t\tMain.debug('-->Static flag set');\n\t\t\t\t\t} else if (currToken.token == AS3MemberType.VAR || currToken.token == AS3MemberType.CONST)\n\t\t\t\t\t{\n\t\t\t\t\t\tMain.debug('--->Member type \"variable\" set.');\n\t\t\t\t\t\tcurrMember = currMember.createVariable(); //Transform the member into a variable\n\t\t\t\t\t\tstack.push(AS3ParseState.MEMBER_VARIABLE);\n\t\t\t\t\t} else if (currToken.token == AS3MemberType.FUNCTION)\n\t\t\t\t\t{\n\t\t\t\t\t\tcurrToken = AS3Parser.nextWord(src, index + 1, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]);\n\t\t\t\t\t\t//Check for getter/setter\n\t\t\t\t\t\tif ((currToken.token == 'get' || currToken.token == 'set') && src[index + 1 + currToken.token.length + 1] != '(')\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tMain.debug('--->Member sub-type \"' + currToken.token + '\" set.');\n\t\t\t\t\t\t\tcurrMember.subType = currToken.token;\n\t\t\t\t\t\t\tindex = currToken.index - 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcurrMember = currMember.createFunction(); //Transform the member into a function\n\t\t\t\t\t\tstack.push(AS3ParseState.MEMBER_FUNCTION);\n\t\t\t\t\t\tMain.debug('---->Member type \"function\" set.');\n\t\t\t\t\t}\n\t\t\t\t} else if (getState() == AS3ParseState.MEMBER_VARIABLE)\n\t\t\t\t{\n\t\t\t\t\tcurrToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]);\n\t\t\t\t\tcurrMember.name = currToken.token; //Set the member name\n\t\t\t\t\tMain.debug('---->Variable name declared: ' + currToken.token);\n\t\t\t\t\tindex = currToken.index;\n\t\t\t\t\tif (src.charAt(index) == \":\")\n\t\t\t\t\t{\n\t\t\t\t\t\tcurrToken = AS3Parser.nextWord(src, index, AS3Pattern.VARIABLE_TYPE[0], AS3Pattern.VARIABLE_TYPE[1]);\n\t\t\t\t\t\tindex = currToken.index;\n\t\t\t\t\t\tcurrMember.type = currToken.token;//Set the value type name\n\t\t\t\t\t\tMain.debug('---->Variable type for ' + currMember.name + ' declared as: ' + currToken.token);\n\t\t\t\t\t}\n\t\t\t\t\tcurrToken = AS3Parser.nextWord(src, index, AS3Pattern.ASSIGN_START[0], AS3Pattern.ASSIGN_START[1]);\n\t\t\t\t\tif (currToken.token == \"=\")\n\t\t\t\t\t{\n\t\t\t\t\t\t//Use all characters after self symbol to set value\n\t\t\t\t\t\tindex = currToken.index;\n\t\t\t\t\t\ttmpArr = AS3Parser.extractUpTo(src, index, /[;\\r\\n]/g);\n\t\t\t\t\t\t//Store value\n\t\t\t\t\t\tcurrMember.value = tmpArr[0].trim();\n\t\t\t\t\t\tindex =  tmpArr[1];\n\t\t\t\t\t\t\n\t\t\t\t\t\tcls.membersWithAssignments.push(currMember);\n\t\t\t\t\t}\n\n\t\t\t\t\t//Store and delete current member and exit\n\t\t\t\t\tif (currMember.isStatic)\n\t\t\t\t\t{\n\t\t\t\t\t\tcls.staticMembers.push(currMember);\n\t\t\t\t\t} else\n\t\t\t\t\t{\n\t\t\t\t\t\tcls.members.push(currMember);\n\t\t\t\t\t}\n\t\t\t\t\tcls.registerField(currMember.name, currMember);\n\t\t\t\t\tcurrMember = null;\n\t\t\t\t\tstack.pop();\n\t\t\t\t} else if (getState() == AS3ParseState.MEMBER_FUNCTION)\n\t\t\t\t{\n\t\t\t\t\t//Parse the arguments\n\t\t\t\t\tcurrToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]);\n\t\t\t\t\tindex = currToken.index;\n\t\t\t\t\tcurrMember.name = currToken.token; //Set the member name\n\t\t\t\t\tMain.debug('****>Function name declared: ' + currToken.token);\n\t\t\t\t\t\n\t\t\t\t\tAS3Parser.PREVIOUS_BLOCK = currMember.name + \":Function\";\n\t\t\t\t\ttmpArr = AS3Parser.extractBlock(src, index, '(', ')');\n\t\t\t\t\tindex = tmpArr[1] - 1; //Ending index of parsed block\n\t\t\t\t\ttmpStr = tmpArr[0].trim(); //Parsed block\n\t\t\t\t\ttmpStr = tmpStr.substr(1, tmpStr.length - 2); //Remove outer parentheses\n\t\t\t\t\ttmpArr = null; //Trash this\n\t\t\t\t\ttmpArr = tmpStr.split(','); //Split args by commas\n\t\t\t\t\t//Don't bother if there are no arguments\n\t\t\t\t\tif (tmpArr.length > 0 && tmpArr[0] != '')\n\t\t\t\t\t{\n\t\t\t\t\t\t//Truncate spaces and assign values to arguments as needed\n\t\t\t\t\t\tfor (i = 0; i < tmpArr.length; i++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttmpStr = tmpArr[i];\n\t\t\t\t\t\t\t//Grab the function name\n\t\t\t\t\t\t\ttmpToken = AS3Parser.nextWord(tmpStr, 0, AS3Pattern.VARIABLE[0], AS3Pattern.VARIABLE[1]); //Parse out the function name\n\t\t\t\t\t\t\tcurrMember.argList.push(new AS3Argument());\n\t\t\t\t\t\t\tif (tmpStr.indexOf('...') === 0)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t//This is a ...rest argument, stop here\n\t\t\t\t\t\t\t\tcurrMember.argList[currMember.argList.length-1].name = tmpStr.substr(3);\n\t\t\t\t\t\t\t\tcurrMember.argList[currMember.argList.length-1].isRestParam = true;\n\t\t\t\t\t\t\t\tMain.debug('----->Parsed a ...rest param: ' + currMember.argList[currMember.argList.length-1].name);\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t} else\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcurrMember.argList[currMember.argList.length-1].name = tmpToken.token; //Set the argument name\n\t\t\t\t\t\t\t\tMain.debug('----->Function argument found: ' + tmpToken.token);\n\t\t\t\t\t\t\t\t//If a colon was next, we'll assume it was typed and grab it\n\t\t\t\t\t\t\t\tif (tmpToken.index < tmpStr.length && tmpStr.charAt(tmpToken.index) == ':')\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttmpToken = AS3Parser.nextWord(tmpStr, tmpToken.index, AS3Pattern.VARIABLE_TYPE[0], AS3Pattern.VARIABLE_TYPE[1]); //Parse out the argument type\n\t\t\t\t\t\t\t\t\tcurrMember.argList[currMember.argList.length-1].type = tmpToken.token; //Set the argument type\n\t\t\t\t\t\t\t\t\tMain.debug('----->Function argument typed to: ' + tmpToken.token);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\ttmpToken = AS3Parser.nextWord(tmpStr, tmpToken.index, AS3Pattern.ASSIGN_START[0], AS3Pattern.ASSIGN_START[1]);\n\t\t\t\t\t\t\t\tif (tmpToken.token == \"=\")\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t//Use all characters after self symbol to set value\n\t\t\t\t\t\t\t\t\ttmpToken = AS3Parser.nextWord(tmpStr, tmpToken.index, AS3Pattern.ASSIGN_UPTO[0], AS3Pattern.ASSIGN_UPTO[1]);\n\t\t\t\t\t\t\t\t\tif (!tmpToken)\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tthrow new Error(\"Error during variable assignment in arg\" + currMember.argList[currMember.argList.length - 1].name);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t//Store value\n\t\t\t\t\t\t\t\t\tcurrMember.argList[currMember.argList.length-1].value = tmpToken.token.trim();\n\t\t\t\t\t\t\t\t\tMain.debug('----->Function argument defaulted to: ' + tmpToken.token.trim());\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tMain.debug('------>Completed paring args: ', currMember.argList);\n\t\t\t\t\t//Type the function if needed\n\t\t\t\t\tif (src.charAt(index + 1) == \":\")\n\t\t\t\t\t{\n\t\t\t\t\t\ttmpToken = AS3Parser.nextWord(src, index + 1, AS3Pattern.VARIABLE_TYPE[0], AS3Pattern.VARIABLE_TYPE[1]); //Parse out the function type if needed\n\t\t\t\t\t\tindex = tmpToken.index;\n\t\t\t\t\t\tcurrMember.type = tmpToken.token;\n\t\t\t\t\t\tMain.debug('------>Typed the function to: ', currMember.type);\n\t\t\t\t\t}\n\n\t\t\t\t\t\n\t\t\t\t\tif (cls.isInterface)\n\t\t\t\t\t{\n\t\t\t\t\t\t//Store and delete current member and exit\n\t\t\t\t\t\tcurrMember.value = '{}';\n\t\t\t\t\t\tif (currMember.subType == 'get')\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t(currMember.isStatic) ? cls.staticGetters.push(currMember) : cls.getters.push(currMember);\n\t\t\t\t\t\t} else if (currMember.subType == 'set')\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t(currMember.isStatic) ? cls.staticSetters.push(currMember) : cls.setters.push(currMember);\n\t\t\t\t\t\t} else if (currMember.isStatic)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcls.staticMembers.push(currMember);\n\t\t\t\t\t\t} else\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcls.members.push(currMember);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcls.registerField(currMember.name, currMember);\n\t\t\t\t\t\t//Done parsing function\n\t\t\t\t\t\tcurrMember = null;\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t} else\n\t\t\t\t\t{\n\t\t\t\t\t\t//Save the function body\n\t\t\t\t\t\tAS3Parser.PREVIOUS_BLOCK = currMember.name + \":Function\";\n\t\t\t\t\t\ttmpArr = AS3Parser.extractBlock(src, index);\n\t\t\t\t\t\tindex = tmpArr[1];\n\t\t\t\t\t\tcurrMember.value = tmpArr[0].trim();\n\n\t\t\t\t\t\t//Store and delete current member and exit\n\t\t\t\t\t\tif (currMember.subType == 'get')\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t(currMember.isStatic) ? cls.staticGetters.push(currMember) : cls.getters.push(currMember);\n\t\t\t\t\t\t} else if (currMember.subType == 'set')\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t(currMember.isStatic) ? cls.staticSetters.push(currMember) : cls.setters.push(currMember);\n\t\t\t\t\t\t} else if (currMember.isStatic)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcls.staticMembers.push(currMember);\n\t\t\t\t\t\t} else\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcls.members.push(currMember);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcls.registerField(currMember.name, currMember);\n\n\t\t\t\t\t\tcurrMember = null;\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t}\n\t\t\t\t} else if (getState() == AS3ParseState.LOCAL_VARIABLE)\n\t\t\t\t{\n\n\t\t\t\t} else if (getState() == AS3ParseState.LOCAL_FUNCTION)\n\t\t\t\t{\n\n\t\t\t\t} else if (getState() == AS3ParseState.IMPORT_PACKAGE)\n\t\t\t\t{\n\t\t\t\t\t//The current token is a class import\n\t\t\t\t\tcurrToken = AS3Parser.nextWord(src, index, AS3Pattern.IMPORT[0], AS3Pattern.IMPORT[1]);\n\t\t\t\t\tindex = currToken.index - 1;\n\t\t\t\t\tif (!currToken.token)\n\t\t\t\t\t{\n\t\t\t\t\t\tthrow new Error(\"Error parsing import.\");\n\t\t\t\t\t} else\n\t\t\t\t\t{\n\t\t\t\t\t\tMain.debug(\"Parsed import name: \" + currToken.token);\n\t\t\t\t\t\tif (currToken.token.indexOf(\"*\") >= 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcls.importWildcards.push(currToken.token); //To be resolved later\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcls.imports.push(currToken.token); //No need to resolve\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstack.push(AS3ParseState.PACKAGE);\n\t\t\t\t\t}\n\t\t\t\t} else if (getState() == AS3ParseState.REQUIRE_MODULE)\n\t\t\t\t{\n\t\t\t\t\t//The current token is a module requirement\n\t\t\t\t\tcurrToken = AS3Parser.nextWord(src, index, AS3Pattern.REQUIRE[0], AS3Pattern.REQUIRE[1]);\n\t\t\t\t\tindex = currToken.index - 1;\n\t\t\t\t\tif(!currToken.token)\n\t\t\t\t\t\tthrow new Error(\"Error parsing require.\");\n\t\t\t\t\telse {\n\t\t\t\t\t\tMain.debug(\"Parsed require name: \" + currToken.token);\n\t\t\t\t\t\tcls.requires.push(currToken.token.trim());\n\t\t\t\t\t\tstack.push(AS3ParseState.PACKAGE);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tpublic function parse(options:Object = null):AS3Class\n\t\t{\n\t\t\toptions = options || { };\n\t\t\tif (typeof options.safeRequire !== 'undefined')\n\t\t\t{\n\t\t\t\tparserOptions.safeRequire = options.safeRequire;\n\t\t\t}\n\t\t\tif (typeof options.ignoreFlash !== 'undefined')\n\t\t\t{\n\t\t\t\tparserOptions.ignoreFlash = options.ignoreFlash;\n\t\t\t}\n\t\t\t\n\t\t\tvar classDefinition:AS3Class = new AS3Class(parserOptions);\n\t\t\tstack.splice(0, stack.length);\n\t\t\tstack.push(AS3ParseState.START);\n\t\t\t\n\t\t\tparseHelper(classDefinition, src);\n\t\t\t\n\t\t\tif (!classDefinition.className)\n\t\t\t{\n\t\t\t\tthrow new Error(\"Error, no class provided for package: \" + classPath);\n\t\t\t}\n\t\t\treturn classDefinition;\n\t\t}\n\t\t\n\t\tpublic static function checkArguments(fn:AS3Function):String\n\t\t{\n\t\t\tif (fn.argList.length <= 0)\n\t\t\t{\n\t\t\t\treturn fn.value;\n\t\t\t}\n\t\t\tvar start:int = fn.value.indexOf('{');\n\t\t\tvar args:String = \"\";\n\t\t\tfor (var i:int = 0; i < fn.argList.length; i++)\n\t\t\t{\n\t\t\t\t//We will inject arguments into the top of the method definition\n\t\t\t\tif (fn.argList[i].isRestParam)\n\t\t\t\t{\n\t\t\t\t\targs += \"\\n\\t\\t\\tvar \" + fn.argList[i].name + \" = Array.prototype.slice.call(arguments).splice(\" + i + \");\";\n\t\t\t\t} else if (fn.argList[i].value)\n\t\t\t\t{\n\t\t\t\t\targs += \"\\n\\t\\t\\t\" + fn.argList[i].name + \" = AS3JS.Utils.getDefaultValue(\" + fn.argList[i].name + \", \" + fn.argList[i].value + \");\";\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn fn.value.substr(0, start + 1) + args + fn.value.substr(start + 1);\n\t\t}\n\t\tpublic static function injectInstantiations(cls:AS3Class, fn:AS3Function):String\n\t\t{\n\t\t\tvar start:int = fn.value.indexOf('{');\n\t\t\tvar text:String = \"\";\n\t\t\tfor (var i = 0; i < cls.members.length; i++)\n\t\t\t{\n\t\t\t\t//We will inject instantiated vars into the top of the method definition\n\t\t\t\tif (cls.members[i] instanceof AS3Variable && AS3Class.nativeTypes.indexOf(cls.members[i].type) < 0)\n\t\t\t\t{\n\t\t\t\t\ttext += \"\\n\\t\\t\\tthis.\" + cls.members[i].name + \" = \" + cls.members[i].value + \";\";\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn fn.value.substr(0, start + 1) + text + fn.value.substr(start + 1);\n\t\t}\n\t\tpublic static function injectInit(cls:AS3Class, fn:AS3Function):String\n\t\t{\n\t\t\tvar start:int = fn.value.indexOf('{');\n\t\t\tvar text:String = \"\\n\\t\\t\\tthis.$init();\";\n\t\t\t\n\t\t\treturn fn.value.substr(0, start + 1) + text + fn.value.substr(start + 1);\n\t\t}\n\t\tpublic static function checkStack(stack:Array, name:String):void\n\t\t{\n\t\t\tif (!name)\n\t\t\t{\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tfor (var i = stack.length - 1; i >= 0; i--)\n\t\t\t{\n\t\t\t\tif (stack[i].name == name)\n\t\t\t\t{\n\t\t\t\t\treturn stack[i];\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\tpublic static function lookAhead(str:String, index:int):Object\n\t\t{\n\t\t\t//Look ahead in the function for assignments\n\t\t\tvar originalIndex:int = index;\n\t\t\tvar startIndex:int = -1;\n\t\t\tvar endIndex:int = -1;\n\t\t\tvar semicolonIndex:int = -1;\n\t\t\tvar token:String = \"\";\n\t\t\tvar extracted:String = \"\";\n\t\t\t//Not a setter if there is a dot operator immediately after\n\t\t\tif (str.charAt(index) == '.')\n\t\t\t{\n\t\t\t\treturn { token: null, extracted: '', startIndex: startIndex, endIndex: endIndex };\n\t\t\t}\n\t\t\tfor (; index < str.length; index++)\n\t\t\t{\n\t\t\t\tif(str.charAt(index).match(/[+-\\/=*]/g))\n\t\t\t\t{\n\t\t\t\t\t//Append to the assignment instruction\n\t\t\t\t\ttoken += str.charAt(index);\n\t\t\t\t\tstartIndex = index;\n\t\t\t\t} else if (startIndex < 0 && str.charAt(index).match(/[\\t\\s]/g)) //Skip these characters\n\t\t\t\t{\n\t\t\t\t\tcontinue;\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tbreak; //Exits when token has already been started and no more regexes pass\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t//Only allow these patterns\n\t\t\tif (!(token == \"=\" || token == \"++\" || token == \"--\" || token == \"+=\" || token == \"-=\" || token == \"*=\" || token == \"/=\"))\n\t\t\t{\n\t\t\t\ttoken = null;\n\t\t\t}\n\t\t\t\t\n\t\t\tif (token)\n\t\t\t{\n\t\t\t\t//Pick whatever is closer, new line or semicolon\n\t\t\t\tendIndex = str.indexOf('\\n', startIndex);\n\t\t\t\tif (endIndex < 0)\n\t\t\t\t{\n\t\t\t\t\tendIndex = str.length - 1;\n\t\t\t\t}\n\t\t\t\t//Windows fix\n\t\t\t\tif (str.charAt(endIndex - 1) == '\\r')\n\t\t\t\t{\n\t\t\t\t\tendIndex--;\n\t\t\t\t}\n\t\t\t\t//We want to place closing parens before semicolon if it exists\n\t\t\t\tsemicolonIndex = str.indexOf(\";\", startIndex);\n\t\t\t\tif (semicolonIndex < endIndex)\n\t\t\t\t{\n\t\t\t\t\tendIndex = semicolonIndex;\n\t\t\t\t}\n\t\t\t\textracted = str.substring(startIndex + token.length, endIndex);\n\t\t\t}\n\t\t\t\n\t\t\treturn { token: token, extracted: extracted, startIndex: startIndex, endIndex: endIndex };\n\t\t}\n\t\tpublic static function parseFunc(cls:AS3Class, fnText:String, stack:Array, statFlag:Boolean = false):Array\n\t\t{\n\t\t\tvar i:int;\n\t\t\tvar j:int;\n\t\t\tvar index:int = 0;\n\t\t\tvar result:String = '';\n\t\t\tvar tmpStr:String = '';\n\t\t\tvar tmpArgs:Vector.<AS3Argument>;\n\t\t\tvar tmpMember:AS3Member;\n\t\t\tvar tmpClass:AS3Class;\n\t\t\tvar tmpField:AS3Member;\n\t\t\tvar prevToken:AS3Token;\n\t\t\tvar currToken:AS3Token;\n\t\t\tvar tmpParse:String;\n\t\t\tvar tmpStatic:Boolean = false;\n\t\t\tvar tmpPeek:String;\n\t\t\tvar objBuffer = ''; //Tracks the current object that is being \"pathed\" (e.g. \"object.field1\" or \"object.field1[index + 1]\", etc)\n\t\t\tvar justCreatedVar:Boolean = false; //Keeps track if we just started a var statement (to help test if we're setting a type))\n\t\t\tfor (index = 0; index < fnText.length; index++)\n\t\t\t{\n\t\t\t\tobjBuffer = '';\n\t\t\t\tprevToken = currToken;\n\t\t\t\tcurrToken = AS3Parser.nextWord(fnText, index, AS3Pattern.VARIABLE[0], AS3Pattern.VARIABLE[1]);\n\t\t\t\tresult += currToken.extra; //<-Puts all other non-identifier characters into the buffer first\n\t\t\t\ttmpMember = AS3Parser.checkStack(stack, currToken.token); //<-Check the stack for a member with this identifier already\n\t\t\t\tindex = currToken.index;\n\t\t\t\tif (currToken.token)\n\t\t\t\t{\n\t\t\t\t\tif (currToken.token == 'function')\n\t\t\t\t\t{\n\t\t\t\t\t\tvar t1 = AS3Parser.nextWord(fnText, index, AS3Pattern.VARIABLE[0], AS3Pattern.VARIABLE[1]);\n\t\t\t\t\t\tvar t2 = fnText.indexOf('(', index);\n\t\t\t\t\t\t//If the parenthesis si less than the last index of the next parsed variable name\n\t\t\t\t\t\tresult += (t2 < t1.index) ? 'function' : 'function ' + t1.token;\n\t\t\t\t\t\ttmpParse = AS3Parser.extractBlock(fnText, index, '(', ')'); //Parse out argument block\n\t\t\t\t\t\tindex = tmpParse[1]; //Update index\n\t\t\t\t\t\ttmpArgs = AS3Parser.parseArguments(tmpParse[0]); //Extract arg types\n\t\t\t\t\t\t//Join the args together without types\n\t\t\t\t\t\tresult += '(' + (function(args) {\n\t\t\t\t\t\t\tvar arr = [];\n\t\t\t\t\t\t\tfor (var i = 0; i < args.length; i++)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif (args[i] === '...rest')\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tarr.push(args[i].name);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tvar str = arr.join(', ');\n\t\t\t\t\t\t\treturn str;\n\t\t\t\t\t\t})(tmpArgs) + ')';\n\t\t\t\t\t\ttmpParse = AS3Parser.extractBlock(fnText, index, '{', '}'); //Extract function block\n\t\t\t\t\t\tindex = tmpParse[1] - 1; //Update index\n\t\t\t\t\t\ttmpParse = AS3Parser.parseFunc(cls, tmpParse[0], stack.concat(tmpArgs), statFlag); //Recurse into function\n\t\t\t\t\t\tresult += ' ' + tmpParse[0];\n\t\t\t\t\t} else\n\t\t\t\t\t{\n\t\t\t\t\t\tif (currToken.token == 'this')\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t//No need to perform any extra checks on the subsequent token\n\t\t\t\t\t\t\ttmpStatic = false;\n\t\t\t\t\t\t\ttmpClass = cls;\n\t\t\t\t\t\t\tobjBuffer += currToken.token;\n\t\t\t\t\t\t\tresult += currToken.token;\n\t\t\t\t\t\t} else\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (cls.classMap[currToken.token] && cls.parentDefinition !== cls.classMap[currToken.token] && !(justCreatedVar && currToken.extra.match(/:\\s*/g)))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t// If this is a token that matches a class from a potential import statement, store it in the filtered classMap\n\t\t\t\t\t\t\t\tcls.classMapFiltered[currToken.token] = cls.classMap[currToken.token];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttmpStatic = (cls.className == currToken.token || cls.retrieveField(currToken.token, true) !== null);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t//Find field in class, then make sure we didn't already have a local member defined with this name, and skip next block if static since the definition is the class itself\n\t\t\t\t\t\t\t//Note: tmpMember needs to be checked, if something is in there it means we have a variable with the same name in local scope\n\t\t\t\t\t\t\tif (cls.retrieveField(currToken.token, tmpStatic) && cls.className != currToken.token && !tmpMember && !(prevToken && prevToken.token === \"var\"))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttmpMember = cls.retrieveField(currToken.token, tmpStatic); //<-Reconciles the type of the current variable\n\t\t\t\t\t\t\t\tif (tmpMember && (tmpMember.subType == 'get' || tmpMember.subType == 'set'))\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttmpPeek = AS3Parser.lookAhead(fnText, index);\n\t\t\t\t\t\t\t\t\tif (tmpPeek.token)\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t//Handle differently if we are assigning a setter\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t//Prepend the correct term\n\t\t\t\t\t\t\t\t\t\tif (tmpStatic)\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tobjBuffer += (cls.retrieveField(currToken.token, tmpStatic)) ? cls.className + '.' : currToken.token + '.';\n\t\t\t\t\t\t\t\t\t\t\tresult += (cls.retrieveField(currToken.token, tmpStatic)) ? cls.className + '.' : currToken.token + '.';\n\t\t\t\t\t\t\t\t\t\t} else\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tobjBuffer += 'this.';\n\t\t\t\t\t\t\t\t\t\t\tresult += 'this.';\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tobjBuffer += 'get_' + currToken.token + '()';\n\t\t\t\t\t\t\t\t\t\tresult += 'set_' + currToken.token + '(';\n\t\t\t\t\t\t\t\t\t\tindex = tmpPeek.endIndex;\n\t\t\t\t\t\t\t\t\t\tif (tmpPeek.token == '++')\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tresult += objBuffer + ' + 1';\n\t\t\t\t\t\t\t\t\t\t} else if (tmpPeek.token == '--')\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tresult += objBuffer + ' - 1';\n\t\t\t\t\t\t\t\t\t\t} else\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\ttmpParse = AS3Parser.parseFunc(cls, tmpPeek.extracted, stack); //Recurse into the assignment to parse vars\n\t\t\t\t\t\t\t\t\t\t\tif (tmpPeek.token == '=')\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tresult +=  tmpParse[0].trim();\n\t\t\t\t\t\t\t\t\t\t\t} else \n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tresult += objBuffer + ' ' + tmpPeek.token.charAt(0) + ' (' + tmpParse[0] + ')';\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tresult += ')';\n\t\t\t\t\t\t\t\t\t} else\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t//Getters are easy\n\t\t\t\t\t\t\t\t\t\tif (tmpStatic)\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tobjBuffer += (cls.retrieveField(currToken.token, true)) ? cls.className + '.get_' + currToken.token + '()' : 'this.get_' + currToken.token + '()';\n\t\t\t\t\t\t\t\t\t\t\tresult += (cls.retrieveField(currToken.token, true)) ? cls.className + '.get_' + currToken.token + '()' : 'this.get_' + currToken.token + '()';\n\t\t\t\t\t\t\t\t\t\t} else\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tobjBuffer += 'this.get_' + currToken.token + '()';\n\t\t\t\t\t\t\t\t\t\t\tresult += 'this.get_' + currToken.token + '()';\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tif (tmpStatic)\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tobjBuffer += (cls.className == currToken.token) ? currToken.token : cls.className + '.' + currToken.token;\n\t\t\t\t\t\t\t\t\t\tresult += (cls.className == currToken.token) ? currToken.token : cls.className + '.' + currToken.token;\n\t\t\t\t\t\t\t\t\t} else\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tobjBuffer += (cls.retrieveField(currToken.token, false) && !statFlag && !(prevToken && prevToken.token === 'new' && cls.retrieveField(currToken.token, false).type !== \"Class\")) ? 'this.' + currToken.token : currToken.token;\n\t\t\t\t\t\t\t\t\t\tresult += (cls.retrieveField(currToken.token, false) && !statFlag && !(prevToken && prevToken.token === 'new' && cls.retrieveField(currToken.token, false).type !== \"Class\")) ? 'this.' + currToken.token : currToken.token;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t//Likely a local variable, argument, or static reference\n\t\t\t\t\t\t\t\tif (tmpStatic)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tobjBuffer += currToken.token;\n\t\t\t\t\t\t\t\t\tresult += currToken.token;\n\t\t\t\t\t\t\t\t} else\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tobjBuffer += (cls.retrieveField(currToken.token, false) && !tmpMember && !(prevToken && prevToken.token === \"var\")) ? 'this.' + currToken.token : currToken.token;\n\t\t\t\t\t\t\t\t\tresult += (cls.retrieveField(currToken.token, false) && !tmpMember && !(prevToken && prevToken.token === \"var\")) ? 'this.' + currToken.token : currToken.token;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (tmpStatic)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t//Just use the class itself, we will reference fields from it. If parser injected the static prefix manually, we'll try to determome the type of var instead\n\t\t\t\t\t\t\t\ttmpClass = (cls.className == currToken.token) ? cls : (tmpMember) ? cls.classMap[tmpMember.type] || null : null; \n\t\t\t\t\t\t\t} else\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t//Use the member's type to determine the class it's mapped to\n\t\t\t\t\t\t\t\ttmpClass = (tmpMember && tmpMember.type && tmpMember.type != '*') ? cls.classMap[tmpMember.type] : null; \n\t\t\t\t\t\t\t\t//If no mapping was found, this may be a static reference\n\t\t\t\t\t\t\t\tif (!tmpClass && cls.classMap[currToken.token])\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttmpClass = cls.classMap[currToken.token];\n\t\t\t\t\t\t\t\t\ttmpStatic = true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t//If tmpClass is null, it's possible we were trying to retrieve a Vector type. Let's fix this:\n\t\t\t\t\t\t\tif (!tmpClass && tmpMember && tmpMember.type && tmpMember.type.replace(/Vector\\.<(.*?)>/g, \"$1\") != tmpMember.type)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t//Extract Vector type if necessary by testing regex\n\t\t\t\t\t\t\t\ttmpClass = cls.classMap[tmpMember.type.replace(/Vector\\.<(.*?)>/g, \"$1\")] || null;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t//Note: At this point, tmpMember is no longer used, it was only needed to remember the type of the first token. objBuffer will be building out the token\n\t\t\t\t\t\t\n\t\t\t\t\t\t//If this had a variable declaration before it, we will add it to the local var stack and move on to the next token\n\t\t\t\t\t\tif (prevToken && prevToken.token === \"var\")\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tjustCreatedVar = true;\n\t\t\t\t\t\t\tif (cls.retrieveField(currToken.token, tmpStatic))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t//Appends current character index to the result, add dummy var to stack, and move on\n\t\t\t\t\t\t\t\tresult += fnText.charAt(index);\n\t\t\t\t\t\t\t\tvar localVar:AS3Member = new AS3Member();\n\t\t\t\t\t\t\t\tlocalVar.name = currToken.token;\n\t\t\t\t\t\t\t\tstack.push(localVar); //<-Ensures we don't add \"this.\" or anything in front of this variable anymore\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tjustCreatedVar = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\t//We have parsed the current token, and the index sits at the next level down in the object\n\t\t\t\t\t\tfor (; index < fnText.length; index++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t//Loop until we stop parsing a variable declaration\n\t\t\t\t\t\t\tif (fnText.charAt(index) == '.')\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvar parsingVector =  (prevToken && prevToken.token === 'new' && currToken.token === 'Vector');\n\t\t\t\t\t\t\t\tprevToken = currToken;\n\t\t\t\t\t\t\t\tif (parsingVector)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t//We need to allow asterix\n\t\t\t\t\t\t\t\t\tcurrToken = AS3Parser.nextWord(fnText, index, AS3Pattern.VARIABLE_TYPE[0], AS3Pattern.VARIABLE_TYPE[1]);\n\t\t\t\t\t\t\t\t} else\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcurrToken = AS3Parser.nextWord(fnText, index, AS3Pattern.VARIABLE[0], AS3Pattern.VARIABLE[1]);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tresult += currToken.extra; //<-Puts all other non-identifier characters into the buffer first\n\t\t\t\t\t\t\t\tindex = currToken.index;\n\t\t\t\t\t\t\t\tif (tmpClass)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t//This means we are coming from a typed variable\n\t\t\t\t\t\t\t\t\ttmpField = tmpClass.retrieveField(currToken.token, tmpStatic);\n\t\t\t\t\t\t\t\t\tif (tmpField)\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t//console.log(\"parsing: \" + tmpField.name + \":\" + tmpField.type)\n\t\t\t\t\t\t\t\t\t\t//We found a field that matched this value within the class\n\t\t\t\t\t\t\t\t\t\tif (tmpField instanceof AS3Function)\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tif (tmpField.subType == 'get' || tmpField.subType == 'set')\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\ttmpPeek = AS3Parser.lookAhead(fnText, index);\n\t\t\t\t\t\t\t\t\t\t\t\tif (tmpPeek.token)\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t//Handle differently if we are assigning a setter\n\t\t\t\t\t\t\t\t\t\t\t\t\tobjBuffer += '.get_' + currToken.token + '()';\n\t\t\t\t\t\t\t\t\t\t\t\t\tresult += 'set_' + currToken.token + '(';\n\t\t\t\t\t\t\t\t\t\t\t\t\tindex = tmpPeek.endIndex;\n\t\t\t\t\t\t\t\t\t\t\t\t\tif (tmpPeek.token == '++')\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tresult += objBuffer + ' + 1';\n\t\t\t\t\t\t\t\t\t\t\t\t\t} else if (tmpPeek.token == '--')\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tresult += objBuffer + ' - 1';\n\t\t\t\t\t\t\t\t\t\t\t\t\t} else\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttmpParse = AS3Parser.parseFunc(cls, tmpPeek.extracted, stack); //Recurse into the assignment to parse vars\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif (tmpPeek.token == '=')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tresult += tmpParse[0].trim();\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t} else\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tresult += objBuffer + ' ' + tmpPeek.token.charAt(0) + ' (' + tmpParse[0] + ')';\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\tresult += ')';\n\t\t\t\t\t\t\t\t\t\t\t\t} else\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\tobjBuffer += '.get_' + currToken.token + '()';\n\t\t\t\t\t\t\t\t\t\t\t\t\tresult += 'get_' + currToken.token + \"()\";\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t//console.log(\"set get flag: \" + currToken.token);\n\t\t\t\t\t\t\t\t\t\t\t} else\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tobjBuffer += '.' + currToken.token;\n\t\t\t\t\t\t\t\t\t\t\t\tresult += currToken.token;\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t} else\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tobjBuffer += '.' + currToken.token;\n\t\t\t\t\t\t\t\t\t\t\tresult += currToken.token;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} else\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tobjBuffer += '.' + currToken.token;\n\t\t\t\t\t\t\t\t\t\tresult += currToken.token;\n\t\t\t\t\t\t\t\t\t\t//console.log(\"appened typed: \" + currToken.token);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t//Update the type if this is not a static prop\n\t\t\t\t\t\t\t\t\tif (tmpClass && tmpField && tmpField.type && tmpField.type != '*')\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t//Extract Vector type if necessary by testing regex\n\t\t\t\t\t\t\t\t\t\ttmpClass = (tmpField.type.replace(/Vector\\.<(.*?)>/g, \"$1\") != tmpField.type) ? tmpClass.classMap[tmpField.type.replace(/Vector\\.<(.*?)>/g, \"$1\")] || null : tmpClass.classMap[tmpField.type] || null;\n\t\t\t\t\t\t\t\t\t} else\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttmpClass = null;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t//console.log(\"appened untyped: \" + currToken.token);\n\t\t\t\t\t\t\t\t\tobjBuffer += '.' + currToken.token;\n\t\t\t\t\t\t\t\t\tresult += currToken.token;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else if (fnText.charAt(index) == '[')\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t//We now have to recursively parse the inside of this open bracket\n\t\t\t\t\t\t\t\ttmpParse = AS3Parser.extractBlock(fnText, index, '[', ']');\n\t\t\t\t\t\t\t\tindex = tmpParse[1];\n\t\t\t\t\t\t\t\ttmpParse = AS3Parser.parseFunc(cls, tmpParse[0], stack); //Recurse into the portion that was extracted\n\t\t\t\t\t\t\t\t//console.log(\"recursed into: \" + tmpParse[0]);\n\t\t\t\t\t\t\t\tobjBuffer += tmpParse[0]; //Append this text to the object buffer string so we can remember the variable we have accessed\n\t\t\t\t\t\t\t\tresult += tmpParse[0];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttmpStatic = false; //Static can no longer be possible after the second field\n\t\t\t\t\t\t\tif (!fnText.charAt(index).match(/[.\\[]/g)) \n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tobjBuffer = ''; //Clear out the current object buffer\n\t\t\t\t\t\t\t\tindex--;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tindex--;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tindex = currToken.index - 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn [result, index];\n\t\t}\n\t\tpublic static function cleanup(text:String):String\n\t\t{\n\t\t\tvar i:int;\n\t\t\tvar type:String;\n\t\t\tvar params:Array;\n\t\t\tvar val:String;\n\t\t\tvar matches:Array = text.match(AS3Pattern.VECTOR[0]);\n\t\t\t//For each Vector.<>() found in the text\n\t\t\tfor (i in matches)\n\t\t\t{\n\t\t\t\t//Strip the type and provided params\n\t\t\t\ttype = matches[i].replace(AS3Pattern.VECTOR[0], '$1').trim();\n\t\t\t\tparams = matches[i].replace(AS3Pattern.VECTOR[0], '$2').split(',');\n\t\t\t\t//Set the default based on var type\n\t\t\t\tif (type == 'int' || type == 'uint' || type == 'Number')\n\t\t\t\t{\n\t\t\t\t\tval = \"0\";\n\t\t\t\t} else if (type == 'Boolean')\n\t\t\t\t{\n\t\t\t\t\tval = \"false\";\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tval = \"null\";\n\t\t\t\t}\n\t\t\t\t//Replace accordingly\n\t\t\t\tif (params.length > 0 && params[0].trim() != '')\n\t\t\t\t{\n\t\t\t\t\ttext = text.replace(AS3Pattern.VECTOR[1], \"AS3JS.Utils.createArray(\" + params[0] + \", \" + val + \")\");\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\ttext = text.replace(AS3Pattern.VECTOR[1], \"[]\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tmatches = text.match(AS3Pattern.ARRAY[0]);\n\t\t\t//For each Array() found in the text\n\t\t\tfor (i in matches)\n\t\t\t{\n\t\t\t\t//Strip the provided params\n\t\t\t\tparams = matches[i].replace(AS3Pattern.ARRAY[0], '$1').trim();\n\t\t\t\t//Replace accordingly\n\t\t\t\tif (params.length > 0 && params[0].trim() != '')\n\t\t\t\t{\n\t\t\t\t\ttext = text.replace(AS3Pattern.ARRAY[1], \"AS3JS.Utils.createArray(\" + params[0] + \", null)\");\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\ttext = text.replace(AS3Pattern.ARRAY[1], \"[]\");\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tmatches = text.match(AS3Pattern.DICTIONARY[0]);\n\t\t\t//For each instantiated Dictionary found in the text\n\t\t\tfor (i in matches)\n\t\t\t{\n\t\t\t\t// Replace with empty object\n\t\t\t\ttext = text.replace(AS3Pattern.DICTIONARY[0], \"{}\");\n\t\t\t}\n\t\t\t\n\t\t\t//Now cleanup variable types\n\t\t\ttext = text.replace(/([^0-9a-zA-Z_$.])(?:var|const)(\\s*[a-zA-Z_$*][0-9a-zA-Z_$.<>]*)\\s*:\\s*([a-zA-Z_$*][0-9a-zA-Z_$.<>]*)/g, \"$1var$2\");\n\t\t\t\n\t\t\treturn text;\n\t\t}\n\t}\n}"
  },
  {
    "path": "src/com/mcleodgaming/as3js/parser/AS3Token.as",
    "content": "package com.mcleodgaming.as3js.parser \n{\n\tpublic class AS3Token \n\t{\n\t\tpublic var token:String;\n\t\tpublic var index:int;\n\t\tpublic var extra:String;\n\t\t\n\t\tpublic function AS3Token(token:String, index:int, extra:String) \n\t\t{\n\t\t\tthis.token = token;\n\t\t\tthis.index = index;\n\t\t\tthis.extra = extra;\n\t\t}\n\t}\n\n}"
  },
  {
    "path": "src/com/mcleodgaming/as3js/types/AS3Argument.as",
    "content": "package com.mcleodgaming.as3js.types\n{\n\tpublic class AS3Argument extends AS3Variable\n\t{\n\t\tpublic var isRestParam:Boolean = false;\n\t\t\n\t\tpublic function AS3Argument() \n\t\t{\n\t\t\t\n\t\t}\n\t}\n\n}"
  },
  {
    "path": "src/com/mcleodgaming/as3js/types/AS3Function.as",
    "content": "package com.mcleodgaming.as3js.types\n{\n\tpublic class AS3Function extends AS3Member\n\t{\n\t\tpublic var argList:Array;\n\t\t\n\t\tpublic function AS3Function() \n\t\t{\n\t\t\targList = [];\n\t\t}\n\t\tpublic function hasArgument():Boolean\n\t\t{\n\t\t\tfor(var i = 0; i < argList.length; i++)\n\t\t\t\tif(argList[i].name == name)\n\t\t\t\t\treturn true;\n\t\t\treturn false;\n\t\t}\n\t\tpublic function buildLocalVariableStack():Array\n\t\t{\n\t\t\tvar i;\n\t\t\tvar text = value || '';\n\t\t\tvar matches = text.match(/(var|,)(.*?)([a-zA-Z_$][0-9a-zA-Z_$]*):([a-zA-Z_$][0-9a-zA-Z_$]*)/g);\n\t\t\tvar locals = [];\n\t\t\tif(argList) {\n\t\t\t\tfor(i in argList) {\n\t\t\t\t\tlocals.push(argList[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor(i in matches) {\n\t\t\t\tvar tmpVar = new AS3Variable();\n\t\t\t\ttmpVar.name = matches[i].replace(/(var|,)(.*?)([a-zA-Z_$][0-9a-zA-Z_$]*):([a-zA-Z_$][0-9a-zA-Z_$]*)/g, \"$3\");\n\t\t\t\ttmpVar.type = matches[i].replace(/(var|,)(.*?)([a-zA-Z_$][0-9a-zA-Z_$]*):([a-zA-Z_$][0-9a-zA-Z_$]*)/g, \"$4\");\n\t\t\t\tlocals.push(tmpVar);\n\t\t\t}\n\t\t\t\n\t\t\treturn locals;\n\t\t}\n\t}\n}"
  },
  {
    "path": "src/com/mcleodgaming/as3js/types/AS3Member.as",
    "content": "package com.mcleodgaming.as3js.types\n{\n\tpublic class AS3Member \n\t{\n\t\tpublic var name:String;\n\t\tpublic var type:String;\n\t\tpublic var subType:String;\n\t\tpublic var value:String;\n\t\tpublic var encapsulation:String;\n\t\tpublic var isStatic:Boolean;\n\t\t\n\t\tpublic function AS3Member() \n\t\t{\n\t\t\tname = null;\n\t\t\ttype = '*';\n\t\t\tsubType = null,\n\t\t\tvalue = null;\n\t\t\tencapsulation = \"public\";\n\t\t\tisStatic = false;\n\t\t}\n\t\t\n\t\tpublic function createVariable():AS3Variable\n\t\t{\n\t\t\tvar obj = new AS3Variable();\n\t\t\tobj.name = name;\n\t\t\tobj.type = type;\n\t\t\tobj.subType = subType,\n\t\t\tobj.value = value;\n\t\t\tobj.encapsulation = encapsulation;\n\t\t\tobj.isStatic = isStatic;\n\t\t\treturn obj;\n\t\t}\n\t\tpublic function createFunction():AS3Function\n\t\t{\n\t\t\tvar obj = new AS3Function();\n\t\t\tobj.name = name;\n\t\t\tobj.type = type;\n\t\t\tobj.subType = subType,\n\t\t\tobj.value = value;\n\t\t\tobj.encapsulation = encapsulation;\n\t\t\tobj.isStatic = isStatic;\n\t\t\treturn obj;\n\t\t}\n\t}\n}"
  },
  {
    "path": "src/com/mcleodgaming/as3js/types/AS3Variable.as",
    "content": "package com.mcleodgaming.as3js.types\n{\n\t/**\n\t * ...\n\t * @author Greg McLeod\n\t */\n\tpublic class AS3Variable extends AS3Member\n\t{\n\t\tpublic function AS3Variable() \n\t\t{\n\t\t\t\n\t\t}\n\t}\n\n}"
  }
]