A case study is the most simple way to approach PureMVC framework. From this 3rd part, I will show all steps to build your own project. Now we will make the simple application that allows user enter the username and password, then sign in. This application contains a SignIn form.
Starting Flash Develop, and creating a Flex 3 Project. You can name the project whatever you like. By default, your initial structure folder should look like
bin: contains your build files (htmls, swfs, … )
lib: our PureMVC library file (SWC file) should be placed here. Copy PureMVC_AS3_2_0_4.swc file into this folder. Right click on PureMVC_AS3_2_0_4.swc file, and select Add to library.
We need to create a PureMVC-friendly folder structure for our application – right click on src and create org, then within that create three folders named controller, view, model and events, myapp. Finally within view create a folder called components. We should finish with a folder structure that looks like this:
To make the src and lib become base package for our application, you should add 2 folders as classpath. Go to Project / Properties … , when Project Properties dialog appears, select Classpath tab and add 2 folders src, lib as below
The src is now the base package and contains Main.mxml (the Flex entry point, extended by myapp.MainApplication) and ApplicationFacade.as (the PureMVC entry point). The rest of the application will be contained in the other folders.
The controller package contains commands which implement business logic.
The model package contains proxies. All communication between application and the server (login service) will happen within the proxy.
The view package contains mediators which control components. In some MVC frameworks this folder maybe contain the actual objects that are displayed.
The components packages contains MXML files that will be showed to users and all they are components. When the components change something, they dispatch events, and they might expose public methods which the framework can invoke.
The majority of communication within PureMVC is done using notifications, but the only exception to this is communication from components to their mediators which is done using normal AS3 events.