Using code in both Actionscript3 and Javascript

Posted by Ian on Stack Overflow See other posts from Stack Overflow or by Ian
Published on 2010-04-24T15:39:35Z Indexed on 2010/04/24 15:43 UTC
Read the original article Hit count: 333

Filed under:
|
|

Here's an interesting architectural query. I have a piece of code that needs to run on the server (under Node.js) and on the client (in a Flash 10 app written with Actionscript 3). The code is mostly fairly intricate object manipulation, it doesn't make any API calls, and works fine in both contexts.

So far the project is just a demo, so I've been happy to copy and paste the code into both places. But it might be quite interesting to move forward with this.

So how would you do it?

  • I assume there is no easy way to get the Flash SDK (has to build without an IDE) to read and do something useful with a .js file.

  • My only thought is that I could write a code-generator that takes the .js file and places it in an ActionScript wrapper.

Are there any obvious approaches that I've missed?


Just to pre-empt an obvious answer, I know about cross-platform languages like HaXe.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about actionscript-3