rich Posted April 2, 2013 Share Posted April 2, 2013 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. http://www.photonstorm.com/archives/9815/as3-to-typescript-conversion-script PBMCube 1 Quote Link to comment Share on other sites More sharing options...
Mike Posted April 2, 2013 Share Posted April 2, 2013 Wow i'll take it and try right on the moment. I'll be more than happy if it could convert the ASH as3 game entity framework to typescript. 10x for the efort even before testing, i'll share the result soon i hope Quote Link to comment Share on other sites More sharing options...
rich Posted April 2, 2013 Author Share Posted April 2, 2013 I'm finding and adding new tests as I go (just did another update right then) - but please understand you will still need to do LOADS of work to the code, even after running it through this script. But at least most of the menial stuff will be out of the way for you Quote Link to comment Share on other sites More sharing options...
Mike Posted April 2, 2013 Share Posted April 2, 2013 Of course I don't expect to be compile ready . Here what i'm doing in the moment:1. Conversion when;t perfect2. I've made new VisualStudio Project and imported the ts files3. I go trought every class and fix things in this order: Add import Class = module("path/to/Class"); I tend to make all private variables "_varname" Then goes trought the methods and add "this."And using Web Essential with compile on save, it's quite easy to spot errors... so i'm going to work to see how much time really is SOME NOTES AND QUESTIONS: I think a "int" to "number" will be good convertion too, or no ? What you tend to do with variable types defined like: private somevar: Class;private somevar2: Function; Shouldn;t the convertor "remove :Function" and Class ? Quote Link to comment Share on other sites More sharing options...
rich Posted April 2, 2013 Author Share Posted April 2, 2013 It already does uint/int/Number to number and strips out Class/Function/void vars. There's a full list on the github page of the tasks it performs. Quote Link to comment Share on other sites More sharing options...
Mike Posted April 2, 2013 Share Posted April 2, 2013 Yep, i check the list in github, but the misunderstand came cause in the convertet ts there was : Function and : int ... There was a space, after the colon ": " in the .as files and that left in the .ts So i added lines like this in your php script: $output = str_replace(': Function', '', $output); Quote Link to comment Share on other sites More sharing options...
Ezelia Posted April 2, 2013 Share Posted April 2, 2013 that's awesome ! a good test can be the conversion of box2dflash to TS Quote Link to comment Share on other sites More sharing options...
rich Posted April 2, 2013 Author Share Posted April 2, 2013 The space was to catch Function assignment, rather than a return type, but it's easy enough to swap for a regex that does both. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.