MTASC as your Xcode actionscript compiler!!!
May 11th, 2005It's finally here!! A major piece to the all external xcode flash ide has been created. Thats right, mtasc (Motion-Twin ActionScript 2 Compiler), a stand alone actionscript compiler. Ok.. so this post is a couple months late and mtasc has been out for a while. I've been a little out of the flash loop for the past couple months working at a job that doesn't involve all things actionscript.
One of the great things about using mtasc with xcode is that it adds syntax checking. No longer will you need to remember line numbers and move back and forth between flash and xcode.
Here are the steps I took in getting xcode to compile using mtasc:
2. Move mtasc to a good location. I put it here
/library/application support/apple/developer tools/flash/mtasc/mtasc
3. Create a new "Empty Project" in xcode naming it "firstCompile".
4. Create a new Target. Project->New Taget
5. In the New Target Assistant select "External Target" under "Special Targets" and click next.
6. Name the target "mtasc compile" and click finish
7. In the "Groups & files" section of your project window, expand Targets to reveal the target you just created.
8. Double click on the newly created target to open it's preferences window.
9. Under "Custom Build Command" set the "build Tool" field to the path to mtasc. For me it is:
/library/application support/apple/developer tools/flash/mtasc/mtasc
10. Under "Custom Build Command" set the "Arguments:" field to:
-swf $(PROJECT\_NAME).swf -header 640:480:30 -main $(PROJECT\_NAME).as
11. If you like you can add additional properties under build settings. I created properties for the height, width and fps.
12. close the target window.
13. Create a new file by selecting File->new.
14. Select "Empty File In Project" and click next.
15. Name the file "firstCompile.as" and click finish.
16. Open "firstCompile.as" from the project for editing.
17. add this code:
function firstCompile() {
// creates a 'tf' TextField size 800×600 at pos 0,0
_root.createTextField("tf",0,0,0,800,600);
// write some text into it
_root.tf.text = "Hello world !";
}
// entry point
static function main() {
var t = new firstCompile();l
}
}
18. Save the file then Build the project: Build->Build.
19. If you didn't fix the error in the code you should have gotten an error.
20. Hit Comand = or select "Next build warning or error" from the build menu.
21. The line with the problem will be selected. Fix the line (delete the "l") then build again.
22. Presto!!! A file called "firstCompile.swf" will be created in the directory were your project is saved.
Alright so its all set up. You can now do your actionscript coding without Flash. But one last thing. Lets make it run after its built each time.
23. Create a new target but this time make it a "Shell Script target". Name it "Run swf"
24. Open up the "Run Script" by expanding the target you just created in the "Groups & Fils" window of the project window.
25. In the script area of the window replace what is there with this:
open -a "/Applications/Safari.app" $PROJECT\_NAME".swf"
26. close the window.
27. create another target, this time an "Aggregate", Name it "Build Run".
28. Open the target and click on the General tab.
29. Add "mtasc compile" and "Run swf" — in that order — by clicking the plus button in the lower left corner of the target window.
30. Close the window and go back the project window.
31. From the project menu, select Project -> Set Active target -> "Build Run".
32. And that is it. Build the project again and it will load up your newly complied swf in safari.
You may want to add command-enter support to make it like Flash. It also makes a good template addition.
August 8th, 2005 at 2:13 am
Great tutorial !
There is just something i don't get with the step "Run swf" : when i create a target "Shell script Target", i just get an aggregate like one, with an Shell script files under it in the "group&files" view. I don't know how to obtain a script area from this point…
Anyway, thanks for sharing your experience…
August 8th, 2005 at 8:03 am
Hi Rod,
Thanks, glad its helpful.
The shell script thing got me as well. Make sure your expanding the target in the groups and files window. If you just double click the red target icon you wont get the script window. Expanding the shell script target should reveal an icon with a gray square.
November 20th, 2005 at 10:36 pm
Hi Aaron,
I gave up on trying to get mtasc to work with XCode, but your tutorials have been super helpful. I'm so close to getting it to compile but I'm catching this error: build failed for target "mtasc compile." any suggestions?
thanks, Seth
November 20th, 2005 at 11:57 pm
Hey Seth,
Wordpress was removing a "_" from "$PROJECT_NAME" in step 10 (fixed now). That may be causing the problem. If changing the name doesn't work you can just type in the values instead of using the $PROJECT_NAME build property.
example:
-swf swfName.swf -header 640:480:30 -main asFile.as
Hope that helps,
Aaron
April 19th, 2006 at 4:22 am
Hi,
I have been trying this, but can't get it to work:(
I get,"error: couldn't exec /library/application support/apple/developer tools/flash/mtasc: Permission denied"
Is there a way to fix this?
Thanks
John
September 15th, 2008 at 11:38 am
1- MTASC was never an Actionscript compiler. It was a compiler of an Actionscript modified.
Ej:
- ActionScript is a scripting language based on ECMAScript.
- Javascript 2.0 is a scripting language base on ECMAScript 4.
But they are not the same.
2- If MTASC is really an Actionscript compiler, then I should be able to go to any actionscript website.
Copy any source code (Actionscript 2.0) that I wish to use.
Make a file and compile it using the MTASC.
I don't think this is the case.
3- Since they are not continuing MTASC, the new language is haXe, a multiplatform language. This do not mean that it will accept code written in Javascript, C, C++, Actionscript, etc. This means that you have to program all in this new language that the compiler will compile to another language such as javascript, PHP, swf (note that it does say actionscript), and/or NekoVM (whatever is that).
September 25th, 2008 at 2:03 pm
Axllarus:
1. MTASC is an actionscript 2 compiler.
2. Code copied from other sites should compile with MTASC although there may be some set up involved if the code was meant for the Flash IDE.
3. MTASC and haXe are two different things. MTASC is a compiler. haXe is a programming language. NekoVM is an Apache mod that allows haXe to be used server side.