Search code examples
javascriptapache-flexactionscript

Share code between JavaScript and an ActionScript library without a bridge


I'm involved in writing a Flex/ActionScript library and in the future I will be involved in writing the same library in JavaScript. Rather than writing a library in each language and having to maintain them separately I was wondering if it was possible to:

1) Write the code in one language and share the code into the other e.g. Write the code in JavaScript and use the same .js files in ActionScript

or

2) Write the code in one language and perform a conversion into the other

I know it's possible to communicate between Flash/ActionScript and JavaScript but I'd like to avoid the overheads in using the technology bridge so this isn't really an option.

How do other people deal with writing and maintaining libraries that do exactly the same thing but in different languages? Specifically how do people do this between JavaScript and ActionScript?


Solution

  • How about Haxe.

    You write the code in one language and they can compile it into various forms, including JavaScript files and compiled flash (versions 6-10). They even recently started supporting C++ compilation.

    This would allow you to have the same source code (pre-compilation) for both your JS and AS3 projects.

    (Noticed it when FlashDevelop started supporting it)