Friday, August 27, 2010

Part 1.2 Project Structure.

First of all create a new Flex LIBRARY project. Though we are going to be generating swfs, we aren't going to be having Flex Builder do it.

Why? Well we aren't going to be the only ones creating the swfs. In a properly ordered world, we developers only build our code to test it, make sure it's working, compiling, and then we leave it. If we want to run a Continuous Integration process for example, we need to be building the artifacts in some other way than FB.


Now create the folder structure the same as the image. I'll explain why we have all these top level folders.
  • conf - Short for configuration. This is where we are going to add the files that we use to dynamically configure the application at runtime. We keep these separate from the source files deliberately. These configuration files are able to be changed without (necessarily) recompiling the application.
  • libs - We keep all the libraries for the project. We will have a combination of Flex SWCs and Java JARs in here, split up by language.
  • setup - We are going to be keeping our build files in here along with any other files we use to generate artifacts. This might be additional config files for the Flex compiler for example.
  • src - Our main source directory. All our source code which will end up in production will end up in here.
  • target - This directory can be removed later on as we will be creating it on the fly. This is where all the compiled artifacts end up, this includes production SWFs, SWCs or Test SWFs.
  • test - Where all our test code is going. This includes mocks and additional files in order to create the unit tests.
  • util - This is where all the useful bits and pieces go that don't fit in elsewhere. Server start up scripts, Value Object generation scripts( like xDoclet ), etc.
In preparation for the next part of the tutorial, we're going to add some additional files.
  • Under source, add the following chain of folders com / codecradle / tutorial / application / view
  • In this final folder add a simple HelloWorld MXML application (Hint, don't choose new MXML Application under the context menu, choose MXML component and then set up the application manually. If you choose the MXML Application, FB tries to do all sorts of clever things we don't want it to do). We'll call this something nice and imaginative... like Tutorial.mxml ;)
  • Change the output folder in FB to "target" rather than "bin" just so FB doesn't keep trying to create it.
So by the end of this part, we should have something like the image below. Like all the other parts of this tutorial, add a comment if you have any questions!

No comments:

Post a Comment