If you ever wanted to create stunning flash effects and animations, but the huge amount of money to put into Flash or Flex authoring software kept you away from doing so you’ll be happy to hear:
Flash is free now! Okay, not really, but at least there is an ActionScript 3.0 compiler for free.
Enthusiasm gone? Come on, remember the good old coding days spending hours searching through manuals instead of finding the right gui tab to click on. But mind the positive. Speed and a huge open source community. So let’s start off.
1. Download compiler
Well first you have to download the free Flex SDK that includes the compiler. Flex SDK? Yeah, not only Flash uses AS, so does Flex and AIR:
Now unpack the zip to a folder and move it to a folder the compiler can rest like your app folder. I recommend renaming it to a pretty name, in my case flex_sdk.
Now if you’re on Windows you can be happy and mock the Mac and Linux Guys jumping to step 3.
2. Create startup script (OS X and Linux only)
Actually there is a startup script for the java compiler. The Windows mxmlc.exe simply calls it, but in the OS X and Linux environment there’s often an error:
- bad interpreter: No such file or directory
That’s got something to do with line-endings and stuff, and it is fixable somehow but i decided to simply write my own little bash script wherein I set the paths to the compiler once, and voila, trouble’s gone.
ascompiler in /Users/funkalicious/flash/flex_sdk
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #! /bin/sh #ActionScript 3.0 Compiler using the free mxmlc Java compiler #setup as=$1; compiler="/Users/funkalicious/flash/flex_sdk/lib/mxmlc.jar"; #set path here flexlib="/Users/funkalicious/flash/flex_sdk/frameworks"; #set path here if test -r $as then #compile echo Compiling $as... java -Xmx384m -Dsun.io.useCanonCaches=false -jar $compiler +flexlib=$flexlib $as exit 1; else echo $as not found... exit 0; fi |
3. Compile ActionScript 3.0
Welcome back Windows Guys. You might have missed one important piece of information. Whatever happens, in the end you’ll compile with the java compiler. So let’s start compiling:
- Windows: /bin/mxmlc.exe YourActionScriptDocumentClass.as
- OS X and Linux: ./ascompiler YourActionScriptDocumentClass.as
Now it might take a while to startup the Java Virtual Machine in the background but you’ll notice a wonderful *.swf file as it is finished. Completely free!
Additionally it’s to be said that all dependencies are compiled automatically too, so you don’t have to juggle around with linkage and stuff, just pass it the Document Class and all will be fine.
Without a trace?
Here’s the big but. You already searched one, right? Yeah, it’s pretty unlikely that Adobe delivers us super comfortable code editing in our favourite editor without even spending a dollar. The problem is the tracing. When I develop flash apps I often spend hours watching dump traced out variable contents while shuffling around in my swf. But even if it might sound 1.0, it’s way better than having no output at all.
And that’s the problem. The standard flash player, standalone or not, simply doesn’t provide a console. There is a debug version of the player but it’s also impossible there. You’ll have to put a TextField on the Main Stage or use some kind of third party plugins. But I’ll be back on that topic soon.




7 Responses to “ActionScript 3.0 with MXMLC on Mac OS X”
Jan 21, 2009
Useful information indeed!
Without a trace? You could import a logger class such as ThunderBoltAS3 and use its console to get the messages spitted from within your class.
Jan 21, 2009
Link~
http://code.google.com/p/flash-thunderbolt/wiki/ThunderBoltAS3
Jan 21, 2009
@Rey, thanks I already wrote a new article on a really cool trace tool but thank you anyway!
May 18, 2009
Hello, thanks for this. but it seems that on DV3.5 -Xmx384 gives issues with heap.
Ppl with problems can try -Xmx256, seem to work fine.
Aug 19, 2009
This script is not working for me on OS X.
I’m getting the following output for my Container.as file.
as:file(=) Can’t open source file for input! No such file or directory.
Container.as:0:End of file before newline in // comment
Container.as:0:End-of-File not at end of a line
Container.as:0:End-of-File not at end of a line
Container.as:unknown:Partial line at end of file ignored
Compiling …
Loading configuration file /Applications/flex-sdk/frameworks/flex-config.xml
Error: a target file must be specified
Use ‘mxmlc -help’ for information about using the command line.
Aug 19, 2009
Okay, I take that back… I re-copied the script and it now works fine.
Who knows?
Mar 21, 2010
Hallöchen
Geniales Post. Da hat mich Google wie schon so oft an einen hervorragenden Blog geschickt.
Viele Grüße aus Bantai
Post a Comment