I would like to do some Flash development on my MacBook, utilizing the Flex 3 SDK to compile Actionscript 3 into SWF movies.
How would I set up my Mac to do this?
I would also like to understand how the flash compiler interprets package names into a directory structure.
I took a Flash class in high school, but it relied very heavily on the use of the Adobe Flash IDE, and focused very much on graphical development as opposed to programming and OOP.
I would like to, for example, have an Application class, which would serve as the stage, and multiple other AS3 classes to serve as other MovieClips, Sprites, etc. When I build/compile, all classes in the project directory should be built into a single .swf file.
Is this situation realistic? Achievable? If so, how do I get there?
Thanks!
Best Answer
What is your technical background Austin? If you are coming from a pure art background then it may be a little more difficult to explain everything you need.
First, you need to download the Flex SDK. When you uncompress the directory you get from the download you will see a folder
bin
. Inside the bin are a number of executables that can be used to compile Flex. The one you want is calledmxmlc
. You can link that into your /usr/local/bin or just add the folder to your PATH.If you create a simple file:
save it anywhere (I'll use /tmp/flash/) as TestSWF.as
From the Terminal command prompt type:
You'll see the output:
To compile another file create another directory:
Make a new file in that new model directory called
TestModel.as
Note how the package definition has the name
model
and the directory name is also model. That is how packages work. The package name matches the directory name. If you go deeper into directories (e.g. model/helper/FileLoader.as) then the package name switches the directory/
for a period (e.g. import model.helper.FileLoader)Change TestSWF to be:
once again run:
You'll see the output:
mxmlc will automatically find the class model.TestModel because it by default includes the main files root directory in the class path.
This is the most basic possible way to compile files. It will serve for testing, playing around and very small projects. If you plan to develop professionally or very large projects I suggest using a better IDE (e.g. Flex Builder) or at least a decent build system (e.g. ant). The main advantage to Flex Builder or other Flex specific IDE's is that they hide a lot of the complexity that is normal when building/compiling software.