Part 1 – Frameworks
Part 2 – Directory structure
Part 3 – Application and ApplicationFacade
Part 4 – Notifications, Commands & Use Cases
Part 5 – Model & Proxy
Part 6 – The Application View & Mediator
Part 7 – The Login View & Mediator
Part 8 – The Roster View & Mediator
Part 9 – The Chat View & Mediator
Conclusion, Demo & Downloads
Every application needs an entry point. PureMVC projects can in fact be thought of as having two entry points – one is the AVM entry point; the first class that is actually executed (this is the ‘real’ entry point). The other is the ApplicationFacade which kicks off the PureMVC framework and this is the class that should be considered the centre of our application.
FlashDevelop will probably have automatically created an entry point called Main.mxml – go ahead and delete this at this point as we will be replacing it with our own file.
Our ‘Flex’ entry point will be called Application.mxml (my PureMVC project entry points are always named Application.mxml or Application.as – I’m not sure if this is an official PureMVC naming convention but its always a good idea to decide on a naming scheme and them stick to it). Navigate to the org.davekeen.xiffer directory in the project area of FlashDevelop, right click and select Add->New MXML File… and in the prompt box name the new file Application.mxml and click OK.
Here’s the code for our application entry point:
This MXML file has no function at all apart from sending a STARTUP notification, which will kick off our PureMVC application. Later we’ll add the top-level view components to this, but for now we’re just interested in getting the basic framework up and running. In order to let FlashDevelop know that this is the entry point right-click the file in the project area and select Always Compile from the popup menu.
Now we need the ApplicationFacade. Right click on the xiffer folder in the project area and select Add->New ApplicationFacade… and name it ApplicationFacade.as. If you can’t see New ApplicationFacade… in the Add menu be sure you have installed the PureMVC FlashDevelop templates from PureMVC: First thoughts & FlashDevelop templates correctly.
Finally we need a StartupCommand. Right click on the controller folder and select Add->New SimpleCommand… and name it StartupCommand.as. Let go for a classic – in the execute method add:
Your StartupCommand.as should now look like this:
And there we have a working Flex/PureMVC HelloWorld application! Run it and feel proud 🙂