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
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>
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
Michal, rename the “lib” folder to “libs” because this is where FB3 expects the SWC files.
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
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
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
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,
[...] PureMVC Startup Manager. [...]
[...] 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 [...]
@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
@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
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.
[...] persons who are interested in PureMVC, here is a short tutorial how use it with [...]
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.
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 ?
Hi Stefan,
I am facing an issue with StartupResourceProxy.requires property. I have one appConfig xml file which has all the application configuration data. I am using the Startup Manager setup as in your tutorial. The source URL for the second data item to be loaded is from the first data xml. Even if I am using the following code, rFeedDataProxy.requires = [ rConfigDataProxy ]; the first one starts loading even before the first one complete its loading. Could you pls advice how this happens and how to solve this….
Thanks,
LINTO
[...] Flex and PureMVC Building a flash site using PureMVC From Cairngorm to PureMVC : a quick comparison Getting started with the PureMVC Startup Manager – Introduction Other: PureMVC Introduction(slideshow) Intro to PureMVC(video) We prefer PureMVC [...]
Thanks for taking the time and effort to write this tutorial. Had a quick scan through it and will spend some time implementing this in my own projects.
Cheers!
Just want to let you know that there is a new release of this utility and, importantly, that it has been renamed to Loadup. The new name is intended to avoid the implication that the utility is only relevant at application startup. The two demos have been upgraded and renamed also, so we now have Loadup Utility and demos Loadup as Ordered and Loadup for Assets. Here is a link to the PureMVC forum
http://forums.puremvc.org/index.php?board=45.0
—-Philip
great tut! thanks
Thanks for sharing these clear and straight forward explanations!
All I can say is Thanks…Thanks…Thanks.. I’ve got like 999,997 more to go but you get the point. This tutorial is clear and so well written and cleared up a ton for me as far as the startup manager and a lot of other elements that had evaporated in my time away from puremvc and that I needed 911 stylie right about now!
[...] Getting Started PureMVC with ActionScript [...]
hey man, this is awesome and the daisy chain of tasks before presenting the first view was the way i developed in the past and hated it because it was my only option. this works great in Flex 3 as an Actionscript Project… however, when i repurpose this as a Flex project and use the Application it’s seems to not work properly. I can see my trace statements and the stylesheet loads, but it never advances to SiteDataProxy. When i comment out the “rSiteDataProxy.requires …” it does advance but never dispatch the “Loading Complete”… so i never get the “Site Data Loaded” notification. any suggestions? i really like this concept and would love to implement it as i have a series of Remoting calls that configure and application and i would rather not set some timer that continues to check for 5 of 5 calls complete if you know what i mean
repetita juvant:
Thanks for sharing these clear and straight forward explanations!
Блог просто супер, буду рекомендовать друзьям!
Hello,
Thanks for the clear step by step process.I completed all the steps as given in the lessons but it is still giving errors-
—————————————————–
_monitor.defaultRetryPolicy = 30; ,it is not giving “defaultRetryPolicy attribute”,
StartupMonitorProxy.LOAD_RESOURCES_REJECTED, it is not giving “LOAD_RESOURCES_REJECTED” attribute
Also how to call the Main.as class,i mean how to use it to display everything.
Please do suggest.
Thanks.
Abhilash
I’m new to PureMVC and I’m trying to work in Flash CS4, not FlexBuilder or Air. Seems like all the examples require MXML/Flex (not .fla) “holders”. I think I’m understanding the concepts and what’s being “done” by the code, but how do I instantiate this through a fla? I keep looking for a fla file in source code for the various PureMVC demos and there ain’t none! Maybe it’s just because I’m a newbie, but doesn’t anyone use PureMVC for Flash?