PureMVC Architects Lounge

PureMVC Manifold => Demos and Utils => Topic started by: puremvc on February 17, 2008, 12:53:27



Title: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: puremvc on February 17, 2008, 12:53:27
This demo illustrates the use of the PureMVC framework, the Startup Manager Utility, and the Asynchronous Stub utility to orchestrate an ordered startup process, where Model resources must be loaded in a specific order.

The demo is located here: http://trac.puremvc.org/Demo_AS3_Flex_StartupAsOrdered

The author is Philip Sexton.

NOTE: This project is now known as LoadupAsOrderd, and was renamed when StartupManager was renamed Loadup, to dispel the notion that the utility it was only usable at startup time.

The new thread is here: http://forums.puremvc.org/index.php?topic=1396.0


Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: Flamaker on April 28, 2008, 11:10:35
Great demo that illustrates the two utilities working together.
Is there an easy way to mock/simulate loaded objects and their loading status?


Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: philipSe on May 07, 2008, 03:36:08
Is there an easy way to mock/simulate loaded objects and their loading status?
I presume you mean by using AsyncStub.  I haven't focussed on this use, though I can see how one would think that would be an obvious use for it.  Whether it is a good fit for this purpose, in practice, is a good question.
----Philip   


Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: philipSe on May 07, 2008, 03:40:08
By the way, if there are further postings that relate particularly to AsyncStub, it would be best to post them under the AsyncStub topic.
----Philip


Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: log2e on May 19, 2008, 02:43:49
I put together a three-parts tutorial on using the PureMVC Startup Manager. The 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.

Getting Started with the PureMVC Startup Manager
Introduction (http://blog.log2e.com/2008/05/19/getting-started-with-the-puremvc-startup-manager-introduction/)
Part 1 (http://blog.log2e.com/2008/05/16/getting-started-with-the-puremvc-startup-manager-part-1/)
Part 2 (http://blog.log2e.com/2008/05/17/getting-started-with-the-puremvc-startup-manager-part-2/)
Part 3 (http://blog.log2e.com/2008/05/19/getting-started-with-the-puremvc-startup-manager-part-3/)



Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: philipSe on May 23, 2008, 02:42:12
Well done with the tutorial.  It's great that you've taken the time to hand on the benefits of your  own experience in this way.
----Philip


Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: harmanjd on June 05, 2008, 10:28:07
Question about the tutorial:

In part 2 you have made the statement:

Lines 33-37: The before mentioned utility commands are registered. It’s important that the commands are registered separately with the “Loaded” and “Failed” notification names for every single startup resource.


Why is it important that there are different notification names for every startup resource?




Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: log2e on June 05, 2008, 11:46:08
harmanjd: Otherwise you won't be able to monitor which resource did well and which one did not.


Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: harmanjd on June 06, 2008, 07:13:16
But - the notifications carry the resource name in the body. 


Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: puremvc on June 08, 2008, 07:20:51
Version 1.5 of the Startup As Ordered demo is now available for download. Peter has added some nice functionality allowing you to modify the default properties (such as max retries) before running.

-=Cliff>


Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: philipSe on June 09, 2008, 03:17:53
Major point...
This release of StartupAsOrdered requires the latest version of the StartupManager utility, i.e. it will not work with version 1.2 of StartupManager.  That latest version of StartupManager has not yet been tagged for official release.

Minor point...
Just to avoid confusion. let me clarify that Cliff means 'Philip' not 'Peter'; for some reason this naming error with Philip is a common occurrence among people in general - sometimes Peter is used, sometimes Paul is used.

----Philip


Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: puremvc on June 09, 2008, 06:21:40
Sorry about that Phillip. I'm starting to get a little scatter-brained with everything going on.

And I will get the util bagged and tagged today.

-=Cliff>


Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: justSteve on June 19, 2008, 05:06:32
A couple questions about the updated version as regards the open-ended resource list feature...the 'open-endedness' is meant to accommodate those resource lists where contents are generated at runtime?

On one hand, it seems like either SalesOrder or Invoice would fall into that category - one customer : many invoices. But wouldn't then the proxy have code that first discovered how many invoices/orders are to be loaded and then begin the loading process?

thx
--steve...


Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: philipSe on June 19, 2008, 07:36:42
Yes Steve, I'm sure one could interpret the role of these entities in that way.  The key point was that I didn't choose to put any further effort into the demo, to have it illustrate any more of the startup manager features.

The only reference to the open-ended resource list feature is the block of code commented in the LoadResourcesCommand class.  I included this just as an illustration of how to use this feature and so that a developer could easily activate it instead of the standard code and thus rebuild the demo and see the altered execution.

Of course the option is there for somebody to enhance the demo or make a different demo.
----Philip


Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: justSteve on July 07, 2008, 03:09:34
I'm trying to implement StartUpAsOrdered under the MultiCore model...I've swapped out the 2_0_1.swc for the MultiCore_1_0.swc and updated all imports so they point to the correct package.

I've also updated the getInstance method to use the multicore version:
        public static function getInstance( key:String ) : ApplicationFacade
        {
            if ( instanceMap[ key ] == null ) instanceMap[ key ] = new ApplicationFacade( key );
            return instanceMap[ key ] as ApplicationFacade;
        }

The project tosses 5 different 1046 compiler errors without pinpointing what class(es) are the cause:

1046: Type was not found or was not a compile-time constant: [org.puremvc.as3.interfaces]::ICommand.      StartupAsOrdered   Unknown   1215423380250   6951
1046: Type was not found or was not a compile-time constant: [org.puremvc.as3.interfaces]::ICommand.      StartupAsOrdered   Unknown   1215423380250   6952
1046: Type was not found or was not a compile-time constant: [org.puremvc.as3.interfaces]::IProxy.      StartupAsOrdered   Unknown   1215423380265   6953
1046: Type was not found or was not a compile-time constant: [org.puremvc.as3.interfaces]::IProxy.      StartupAsOrdered   Unknown   1215423380281   6954
1046: Type was not found or was not a compile-time constant: [org.puremvc.as3.interfaces]::IProxy.      StartupAsOrdered   Unknown   1215423380312   6955


I've double checked that any class implementing either ICommand or IProxy is, in fact, importing the multicore package - for grins I've re-added the standard 2_0_1.swc and now get different compiler errors. Since I changed no source code at all - just added the original swc back to the lib folder - it looks like perhaps the StartupManager utility might have dependency on the standard version?


Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: philipSe on July 07, 2008, 07:50:53
Steve
Just want to make sure you know there is a separate swc for startup manager utility with multicore.  It is under a multicore folder, under trunk in the svn repository.  This is a hurried reply, and hence unable to be more precise.
Good luck.
----Philip


Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: justSteve on July 07, 2008, 09:07:30
Opps....that'd be the problem. Sry.


Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: philipSe on July 07, 2008, 09:55:06
Steve
Ok, now I can be more precise - tis the bin folder.

For startup manager utility, in the bin folder under trunk in the svn repository, there are 2 swcs, one for standard and one for multicore, the latter being named Utility_AS3_MultiCore_StartupManager_1_3.swc.  I haven't actually used this myself, but I would encourage its use and would appreciate feedback.

This bin folder is not part of any tagged release, as far as I know.

Cliff, what is the best way to make this available?  Is there read access to the repository?

Hopefully, this swc will resolve your problem.
Regards
----Philip






Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: justSteve on July 07, 2008, 12:31:54
Using the MultiCore version:

Severity and Description   Path   Resource   Location   Creation Time   Id
1046: Type was not found or was not a compile-time constant: [org.puremvc.as3.interfaces]::IProxy.      StartupAsOrdered   Unknown   1215456244359   7070
1136: Incorrect number of arguments.  Expected 0.   StartupAsOrdered/src/org/puremvc/as3/demos/flex/startupasordered   ApplicationFacade.as   line 48   1215456244359   7068
1203: No default constructor found in base class org.puremvc.as3.multicore.patterns.facade:Facade.   StartupAsOrdered/src/org/puremvc/as3/demos/flex/startupasordered   ApplicationFacade.as   line 1   1215456244359   7069


Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: Tekool on July 08, 2008, 04:57:44
Philip, could you please change the constructor arguments of the *StartupMonitorProxy* to let us pass the proxy name as the first argument as usual with PureMVC ?

Something like :
:
public function StartupMonitorProxy ( proxyName:String=NAME, data :IResourceList = null ) should be a good idea.


Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: Tekool on July 08, 2008, 06:03:42
Forgive me, you need to know the exact name of the proxy when you refer to it in *StartupResourceLoadedCommand* or *StartupResourceProxy*.

Nothing too hard to deal with. :)

Sorry.


Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: philipSe on July 08, 2008, 09:01:04
Steve
I don't have a ready answer for you.  The errors seem to be related to startup as ordered, isn't that right?  Where is the reference to the non-multicore IProxy coming from?  I would like to reproduce what you are doing, and then play with it.

Unfortunately. I am on holidays this week and next.  Internet access is not readily available.  And anyway, I'm supposed to be relaxing and so on....

I look forward to seeing info on any progress you make.
----Philip


Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: justSteve on July 09, 2008, 03:53:23

Unfortunately. I am on holidays this week and next.  Internet access is not readily available.  And anyway, I'm supposed to be relaxing and so on....

I look forward to seeing info on any progress you make.
----Philip


You put me in a tough spot here....i don't want to be the source of unrelaxment by putting my problems in front of you - otoh, i don't want to cause stress by not updating on my 'progress'. ;) So in the spirit of 'not my brother's keeper' perhaps you can balance the stress of this puzzle against one of them fancy drinks with the umbrella in 'em.


Using the posted, current version of StartupAsOrdered, multicore, and StartupManager (pulling /scr from the svn trunks rather than the swc) I use a utility that globally searches and replaces text in all the projects files to change:

import org.puremvc.as3.
to:
import org.puremvc.as3.multicore

That requires changing back references to AsynchStub from:
import org.puremvc.as3.multicore.utilities.asyncstub.

back to:
import org.puremvc.as3.utilities.asyncstub.

I'm inclined to trust this method of refactoring (global search/replace) because I'm trusting FlexBuilder to flag any incorrectness, and in fact, if I try to compile at this point i get a complaint about number of arguments for ApplicationFacade.getInstance() - no message about 'type was not found'.

After I correct the signature for calling the AppFacade:

   public static const NAME:String = 'StartupAsOrdered';
   protected var facade:ApplicationFacade = ApplicationFacade.getInstance( NAME );      

The compiler tosses these errors.
:
Severity and Description Path Resource Location Creation Time Id
1046: Type was not found or was not a compile-time constant: [org.puremvc.as3.interfaces]::IProxy. StartupAsOrdered Unknown 1215599616171 7216
1061: Call to a possibly undefined method retryLoadResources through a reference with static type org.puremvc.as3.multicore.utilities.startupmanager.model:StartupMonitorProxy. StartupAsOrdered/src/org/puremvc/as3/demos/flex/startupasordered/view ApplicationMediator.as line 43 1215599616203 7217
1119: Access of possibly undefined property LOAD_RESOURCES_REJECTED through a reference with static type Class. StartupAsOrdered/src/org/puremvc/as3/demos/flex/startupasordered/view ApplicationMediator.as line 54 1215599616203 7218
1119: Access of possibly undefined property LOAD_RESOURCES_REJECTED through a reference with static type Class. StartupAsOrdered/src/org/puremvc/as3/demos/flex/startupasordered/view ApplicationMediator.as line 75 1215599616203 7219

And now, in lieu of my own relaxation, I have a few tons of concrete being air lifting to a new foundation I'm preparing for my new house to get ready for. Come to think of it, you may find the fact that you are (presumably) thousands of miles from my building site/circumstance much more relaxing than a umbrellaed drink!

http://picasaweb.google.com/Am.Steve




Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: philipSe on July 09, 2008, 11:41:42
Steve
Ok, ok, I'm sorry I mentioned the 'relaxing' word.  Good luck with the new house.

You may already know: the multicore src of startupmananager (sm), from which the multicore swc was built, is under the multicore folder in trunk.  It is just standard with the import statements changed.

If there is a problem with this swc, I'm not asking you to resolve it - since I built it I should step forward to resolve it, and will do, and will give it priority over other things (including that r word).

Now, maybe you already believe/know that the prob is with the swc.

If we have the sm multicore swc, plus startupasordered (sao) changed for multicore, plus asyncstub (as) changed for multicore, and we get compile errors that cannot be resolved through sao or as, then it looks like sm is the problem.  Is that where we're at?  I can see that the error line that features 'undefined method retryLoadResources' would seem to indicate an sm error.  And now I realise that this method is superseded by 'tryToCompleteLoadResources()' in this latest sm, which indicates that the sao in use is not the latest version.  The latest sao is required for the latest sm.

Hope this helps.
----Philip


Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: justSteve on July 11, 2008, 04:18:20
Thankx for the wishes of luck. I'm considering planting a sign at the top exit of my driveway so that as they leave, contractors will be reminded to do the same since i've caught a few of them muttering the phrase under their breath. Foundation's poured and curing a few hundred feet away. Bad luck of near biblical proportions are all that separate me from a major sigh of relief scheduled for early next week.
.
.
.

plus asyncstub (as) changed for multicore,

I'd missed this step first (and 2nd) time around.

The latest sao is required for the latest sm.

Yep...i missed that too. After adjusting for multi-core-ness all sm/stub/sao-related errors are eliminated. Hope this message finds you in time to resume some umbrellaed drink relaxation!

tx



Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: philipSe on July 11, 2008, 08:19:53
That's great Steve.  Glad to know you have a clean compile.  BTW, we don't have umbrellas on our drinks in the West Of Ireland.
----Philip


Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: neil on September 16, 2008, 04:11:32
Hi.

I have a Flex/Air project that runs perfectly when run from Flex Builder 3 in either debug or standard mode.
However, when I package the application as an Air installer and install and run it, the application mediator doesn't get called.
I took away the proxy registers from the StartupCommand files and the application mediator was now called, so I added the proxies back one by one, but it seems that it's a random problem not related to the actual proxies that I add back.

My gut feeling is that I need to implement the startupmanager. The model doesn't neccessarily need to be loaded in a specific order, but it may get rid of this problem.

Just to clarify, this only happens when the application is packaged, it doesn't happen when ruuning directly from Flex builder.

Anyone have any ideas?


Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: neil on September 16, 2008, 04:35:36
Okay, this probelm was nothing to do with the order of startup. It was down to the sqlite db file being placed in a different folder than to where it is located when testing/debugging.

I copied over my db file and it all works great now.

Thanks,

Neil


Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: mikih on January 28, 2009, 08:02:45
Hey guys,

first of all - many thanks to all your incredible work on puremvc. I've done 2 successfull projects with it and less pain then with self written mvc frameworks.

In my new project I'm using the StartupManager for loading my init assets. That works really nice. But I also want to use it for...

... loading assets e.g. in the background while user is surfing the website.
... loading assets on demand e.g. a header image per page
... request asset; if loaded retrieve it; if not loaded, start loading; if loading in process, connect listeners to show loading process

I don't know if its the right utility for it. In my last projects I used the Bulkloader to do so....

I'm fine with sending notfications and I understand the differents bewteen frameworks using the flash event handling but it feels more comfortable for the on demand asset loading. For example:

The code is only fictitious to illustrate my approach:
:
In my mediator e.g. HeaderMediator:
var newAsset : AssetProxy = facade.retrieveProxy('images/header/header_xyz.jpg');
if(newAsset) {
  if(newAsset.isLoaded) {
    _headerComponent.update(newAsset.asset.data as UIComponent);
  } else if (newAsset.getBytesLoaded() > 0) {
    newAsset.addEventListener(LoaderEvent.PROGRESS, progressHandler); // e.g. iupdates the progress bar
    newAsset.addEventListener(LoaderEvent.COMPLETE, completeHandler); // updates the asset in the _headerComponent
  }
} else {
  newAsset = facade.registerProxy('images/header/header_xyz.jpg');
  newAsset.addEventListener(LoaderEvent.PROGRESS, progressHandler);
  newAsset.addEventListener(LoaderEvent.COMPLETE, completeHandler);
  newAsset.load();
}

Does anyone has experience for using the AssetLoader for asset loading after startup? I dont want to use two loader utilities.

#####UPDATE: I think that guy has the same problem... http://theresidentalien.typepad.com/ginormous/2009/01/startup-manager-for-puremvc.html


Cheers


Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: philipSe on July 12, 2009, 04:55:59
There is a new version of the Startup As Ordered demo in the code repository; in trunk, not tagged.

Here is the relevant extract from version.txt.

1.6 Presentation improved, to conform better to demo presentation
    standards.  Libs now has PureMVC 2.0.4 and StartupManager 2.0.


Title: Re: Startup as Ordered - A PureMVC AS3 / Flex Demo
Post by: philipSe on July 17, 2009, 03:43:50

See this post: http://forums.puremvc.org/index.php?topic=259.msg6136#msg6136 (http://forums.puremvc.org/index.php?topic=259.msg6136#msg6136)

Arising from that, with reference to my post above about this demo code in the repository trunk, trunk/libs now has the StartupManager 1.6.1 swc.  The 2.0 one, being invalid, has been removed.

My apologies for any inconvenience caused.
----Philip