Getting Started with the PureMVC Startup Manager - Introduction
This three-parts tutorial reflects my own learning experience with the PureMVC framework and the PureMVC Startup Manager. It was inspired by Philip Sexton’s demo Startup as Ordered and is my first attempt on PureMVC. The tutorial’s goal is to provide beneficial information to other novice PureMVC users who have understood the theory but lack practice.
Here’s a short overview of the tutorial’s content:
- Preparing the Project Space
- The Resource Files: styles.css and data.xml
- The StartupMonitorProxy
- The StartupResourceProxy
- “Loaded” and “Failed” Notifications
- Updating the Project Space
- The ApplicationFacade
- The StartupCommand
- The Resource Proxies
- Preparing the View
- The StageMediator
- Testing the Demo
- Conclusion
I closed the comments sections of the three tutorial parts. If you want to discuss the tutorial please add your comments to this introductory post. You can download the sample files from here (the ZIP archive includes a FlashDevelop project file).
And now let’s get started…
Tags: ActionScript, Flash, Flex, PureMVC
May 20th, 2008 at 2:45 am
Stefan,
Thanks for this concise and informative introduction to the StartupManager utility. It is something every PureMVC app needs, and now everyone will have a much easier time understanding how to use it.
I hope you don’t mind, I’ve added a Tutorial link on the StartupManager site pointing directly to this introduction: http://trac.puremvc.org/Utility_AS3_StartupManager
-=Cliff>
May 21st, 2008 at 8:49 am
Hi,
Thanks for this, sounds very clear and concise. One thing though, I cannot get it to run in FlexBuilder3. Could you please provide additional instructions on how your tutorial can be run in FlexBuilder3 please?
Thanks!
Michal
May 21st, 2008 at 9:54 am
Michal, rename the “lib” folder to “libs” because this is where FB3 expects the SWC files.
May 22nd, 2008 at 12:45 am
Thank you for that Stefan.
I have done that earlier, but it’s not working. What seems to be the problem in FB3 is that the Main class is not initialising. And if I do something like
var m:Main=new Main(); in my mxml file after it’s completed creating, I get an error:
Error #1009: Cannot access a property or method of a null object reference.
where the extended ’stage’ object in Main.as is ‘null’ at the time of execution.
Sorry I should’ve made myself clearer in my previous post.
Thank you
Michal
May 22nd, 2008 at 6:43 am
Michal, no need for MXML here at all, it’s a pure AS3 project. I originally set up the project in FlashDevelop, but I’ve just recreated it in FB3, and it works.
1. Create an “ActionScript Project” in FB3.
2. Select “src” as your source folder and “bin” as your output folder.
3. Import the folders/files from my ZIP archive.
4. Make sure that the “Main.as” file is set as default application.
Now for the SWCs. FB3 scans the “libs” folder for SWCs only if it is a Flex project. I didn’t remember that when I wrote my first comment. In an ActionScript project you have to add the “lib”/”libs” folder as a “SWC Folder” manually. Go into the project properties, select “ActionScript Build Path” -> “Library Path” -> “Add SWC Folder” and choose your “lib”/”libs” folder.
Run the project in debug mode so that you can see the trace() messages in the output panel (console).
Here’s a screenshot of my FB3 setup:
http://blog.log2e.com/wp-content/uploads/2008/05/startup_manager_demo_fb3_setup.gif
May 22nd, 2008 at 8:07 am
Thank you for that Stefan,
It worked great. I see now my mistake was trying to set this up as a Flex/AIR application. Which I did figure out eventually, using the default mxml file and call from there to facade.startup(this) rather than using the Main.as file.
Nice work on the tutorial and thanks again for all your help here.
Michal
July 11th, 2008 at 1:11 pm
Hi Stefan,
Many thanks for this very helpfull tutorial.
But I am encountering some difficulties when trying to test the project:
StartupCommand.as, Line 22 1119: Access of possibly undefined property defaultTimeout through a reference with static type org.puremvc.as3.utilities.startupmanager.model:StartupMonitorProxy.
The defaultTimeout property does not exist in the StartupMonitorProxy.as file…
StageMediator.as, Line 28 1119: Access of possibly undefined property LOAD_RESOURCES_REJECTED through a reference with static type Class.
StageMediator.as, Line 51 1119: Access of possibly undefined property LOAD_RESOURCES_REJECTED through a reference with static type Class.
The LOAD_RESOURCES_REJECTED constant does not exist in the StartupMonitorProxy.as file…
Thanks for your help…
Best regards,
July 14th, 2008 at 2:03 pm
[...] PureMVC Startup Manager. [...]
July 21st, 2008 at 12:09 am
[...] behind FB, but in most cases it has everything you need! For persons who are interested in PureMVC, here is a short tutorial how use it with [...]
July 22nd, 2008 at 5:03 am
@Oliver: Which version of the Startup Manager utility do you use? The tutorial is based on version 1.2. Please note that the 1.3 release breaks backward compatibility with the previous release. More information here: http://trac.puremvc.org/Utility_AS3_StartupManager/wiki/ReleaseNotes
July 22nd, 2008 at 11:04 am
@Oliver:
Change to:
_monitor.defaultRetryPolicy = new RetryPolicy(new RetryParameters(0, 0, 30)); in StartupCommand
Remove
case StartupMonitorProxy.LOAD_RESOURCES_REJECTED: from handleNotification
Remove StartupMonitorProxy.LOAD_RESOURCES_REJECTED, from handleNotification
July 23rd, 2008 at 6:13 pm
Great tutorial !
First, I’m French and my english is bad. Sorry.
I’m looking for conrete tutorials that explain PureMVC with pure AS3.
I have understood the theory but I need à “real world” exemple.
Bye…
Pascal.
August 13th, 2008 at 6:09 am
[...] persons who are interested in PureMVC, here is a short tutorial how use it with [...]
September 6th, 2008 at 4:09 pm
Great tutorial
But in trying to compile in the IDE keep getting the following error
1119: Access of possibly undefined property defaultTimeout through a reference with static type org.puremvc.as3.utilities.startupmanager.model:StartupMonitorProxy.
November 19th, 2008 at 12:54 pm
great tutorial ..
in the StartupCommand from the downloaded files you have lines 27 and 28 commented out , but in the tutorial you still refer to these lines, as casting to IStartupProxy.
don’t know which one is correct ?