views:

191

answers:

4

I have some data-crunching code implemented in ActionScript, and I'd like to call it from JavaScript. The related question http://stackoverflow.com/questions/460242/interacting-with-actionscript-2-0-using-javascript mentions the blog post http://blog.circlecube.com/2008/02/01/actionscript-javascript-communication/ which tells me how to do this. All I need now is generating the SWF file from the .as file completely automatically, with a comand-line tool on Linux. How is this possible?

Is there a speed difference between AS2 and AS3?

+3  A: 

Get the free Flex SDK if you are using as3. (Use mtasc if you are using as2)

Simon Groenewolt
Thank you for the link to mtasc, it works for me. Do you have a tutorial for using the Flex SDK from the command line to compile an .as file to an .swf?
pts
You know this handy search engine named google do you? ;-) It gave me this link: http://edutechwiki.unige.ch/en/AS3_Compiling_a_program
Simon Groenewolt
Thank you for the link about how to run the AS3 compiler. This was enough to get me started, and I could figure out all I needed.
pts
+3  A: 

"Is there a speed difference between AS2 and AS3?"

Yes, there is a huge difference, AS3 is much faster, especially in "data-crunching" and such operations, that you mention.

Lars
I'm interested in the numbers. According to my number crunching measurements, AS3 is only 4 times faster than AS2 (I'm not impressed, still 4 times slower than the JavaScript in Google Chrome), but only if I take care of using `int` vs `Number` properly, and using `Vector.<int>` instead of `Array`.
pts
If performance is such a high priority, consider using Silverlight. Or if Chrome can do it faster than both FL/SL, just do it in JS.
Richard Szalay
+2  A: 

Answering my own question, AS3 can be up to 4 times faster than AS2 for number crunching (depending on the code tested), and Flash Player 10 is faster than Flash Player 9, especially Vector.<int> is much faster than Array.

I've summarized automatic SWF generation from AS2 and AS3 sources in my blog post: http://ptspts.blogspot.com/2009/10/how-to-create-actionscript-3-as3-flash.html. I had to collect information for that from dozens of web sites.

pts
+1  A: 

As the others have said yes AS3 is faster than AS2. There are a few other ways to squeeze more performance. One way is pixel bender which you can consider like writing a PixelShader for a GPU except here it is being calculated in software and not hardware. Also Alchemy has shown to improve some performance. Check out http://blog.joa-ebert.com/ The performance Joa is able to gain with various optimisations (some by optimising the byte code) is awesome.

I think this is the article but I am at work so I can not verify. http://blog.joa-ebert.com/2009/04/03/massive-amounts-of-3d-particles-without-alchemy-and-pixelbender/

Allan