Posted on Monday 20 November 2006
Just came back from a week’s vacation in fabulous Quebec City, and glad to share this second draft of the AS2 to AS3 converter. Try it here, download it here.
Since the first version of the converter was quite well-received, I figured I’d revamp the actionscript parser portion of the class to get it beyond a simple list of regex calls and more towards a smart converter. New features include:
- Updates createTextField to new TextField() syntax. Sets x, y, width and height if they are not the default (0). Uses addChildAt unless getNextHighestDepth() is used for argument 2, in which case addChild is used. Parses the first parameter and uses it as the variable name unless it is not a simple string, in which case a temp name is used, and the original name is shown in a comment on top of the block. Pretty sweet.
- Updates getURL to new URLRequest syntax. Works as above.
- Updates var, function and class to public var, public function and public class to remove warnings as requested by my childhood hero Robert Penner. Parses the class to recognize block depth to not affect local vars and inline functions.
- Smarter class and package name recognition.
- Removes unnecessary imports in the same package as the current class.
- Should properly recognize various line endings (crossing fingers).
The zip now includes a command-line executable called convertas2as3 for those Windows users who don’t feel like installing PHP. The zip is pretty big because it includes the php libraries for Windows users. On other platforms you can run the command-line utility in src/convert.php by typing php convert.php at the command line.
If you have any other examples of function calls /without a return value/ that should be updated in a straightforward fashion like getURL and createTextField, you can ask for it, but I am not going to tackle attachMovie and createEmptyMovieClip for reasons I’ve mentioned previously. Enjoy.


