AS3 to TypeScript Conversion Script
I write a lot of HTML5 games and my preferred language of choice is TypeScript. I love the compile-time errors, code-insight and debugging tools it provides. A large part of my work is porting over ActionScript3 code from Flash games. I found that I was going through the same motions over and over again; simple things like changing “Boolean” to “bool”, or rename the class function to “constructor”.
It got to the point where I figured it would save time to write a script to help with the process. So I did, and I’ve released it for anyone else who may benefit from it. The script runs on a local web server and can convert either a single file or a whole directory full of them. It will intelligently deep-scan a folder structure, converting just the ActionScript files that it finds along the way. I’ve successfully run it across the whole of the flixel codebase with no issues, so I’m hopeful it’ll work for you.
It uses a set of 20 conversion tasks, but the list is easy to modify and extend. Indeed if you create new ones (or optimise some of my sucky regexps!) to the benefit other devs then please share them so I can update the script.
Be under no illusion about the amount of work you’ll still have to do once the conversion has run. Properties, vars, native Flash objects and lots of other things will still need fixing and changing by hand. But at least a huge volume of the tedious grunt work will be out of the way. And if it saves you as much time as it has me then that’s just a bonus in my books.
Grab the AS3 to TypeScript Converter from github.
Posted on April 2nd 2013 at 3:10 pm by Rich.
View more posts in ActionScript3. Follow responses via the RSS 2.0 feed.
4 Responses
Leave a commentMake yourself heard
Hire Us
All about Photon Storm and our
HTML5 game development services
Recent Posts
OurGames
Filter our Content
- ActionScript3
- Art
- Cool Links
- Demoscene
- Flash Game Dev Tips
- Game Development
- Gaming
- Geek Shopping
- HTML5
- In the Media
- Phaser
- Phaser 3
- Projects
Brain Food
Hi Rich, sounds like a handy tool, are you using Typescript for all your Javascript games now? Would love to hear more about it, any problems encountered etc… Thanks.
Yes I use TS for nearly all my JS games now. I love it. The only real issue I have with it is that Visual Studio isn’t as good a code editor as Sublime Text 2 is, and I dearly miss a lot of S2 features. But aside from that it’s pretty awesome really
ST2 has support for TypeScript in the wbond package system. I don’t know how robust it is (I’ve only barely touched TS so far), but it’s at least in there.
@Kevin, installed the package and compiled a few scripts with it in sublimetext today. Looking good sofar. I definitly going to use typescript for production. I love it. Sublimetext also blew me away, simple, easy, fast and very feature rich.