PureMVC Architects Lounge

PureMVC Manifold => Demos and Utils => Topic started by: puremvc on February 17, 2008, 04:09:20



Title: Loadup (formerly StartupManager) - A PureMVC AS3 Utility
Post by: puremvc on February 17, 2008, 04:09:20
This utility helps to orchestrate an ordered startup process, where Model resources may need be loaded in a specific order.

The utility is located here: http://trac.puremvc.org/Utility_AS3_Loadup

The author is Philip Sexton.

NOTE: This project 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=1397.0


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: justSteve on March 17, 2008, 02:21:07
Curious to see handling of dynamic resource lists. For example, an app where a search has returned a list of jpgs. Code won't know the names on the list but needs to track which fail - when all have loaded, etc.

Something like:

public function DynamicProxy( rName:String ) {
  var resourceName:String = rName
   super( NAME + '_' + resourceName );
}

mny thx
--steve...


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: james.douma on March 24, 2008, 08:57:13
I'm writing an application that executes RPC calls over XMPP. During startup I want to ...
  • load connection settings
  • create XMPP service
  • login
  • load model resources
  • update UI

Do I need to create separate proxies for each of these operations? How would I use the startup manager otherwise?

Thanks for your help. 


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on March 27, 2008, 04:20:42
Sorry about no replies here; I didn't notice this thread until late yesterday.

Steve
Don't know if you still have this query.  Anyway, some points that might be relevant
  • Reference the API docs for StartupResourceProxy
  • No reason why the app's own resource proxies can't be created dynamically, provided they are named uniquely and implement IStartupProxy
  • The associated StartupResourceProxy objects can also be dynamically created
  • A fresh StartupMonitorProxy is required for each case of resources to load; many apps only need this once, at startup; however, if the needs arises from time to time during app running then just use the startup manager again, but you must recreate StartupMonitorProxy and must  register that new instance so that it replaces any previous one.

James
Take 'load model resources'.  These must be loaded before Update UI can occur, I presume.  So, a run of startup manager could accomplish that, with each model resource having a proxy etc.  Update UI and 'login' sounds like they would not use startup manager.

Maybe 'load connection settings' is a set of resources (one or more, each with a proxy), subject to asynchronous loading that could use the startup manager; maybe login cannot occur until this completes.

See the comment above about using the startup manager more than once.  Maybe you would need to use it twice; once for connection settings and once for model resources.

I hope this reply has not missed the point.
    Philip


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: jowie on March 28, 2008, 10:08:33
Hi there,

I just started using the StartupManager, but I am unsure it is what I am looking for... My problem is that I'm not just loading stuff, I'm also generating stuff in a particular order. In other words, my list of startup 'things' I wish to do in order is:

1. load config
2. generate on-screen graphics based on config data
3. load animations based on config data
4. load music based on config data

preferably with a loader bar as the process is working. However from what I can gleam from this utility, the only extra function implemented is 'load'. Once my config has loaded, I want to call functions with parameters based on data within the configProxy... Though armed with only a 'load' function, I cannot see how this is possible.

Can anyone help?

Thanks!

:-Joe ;)


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on March 28, 2008, 10:37:03
Hi Joe
What about the following approach.

animations requires config
music requires config

Let the animations proxy have a property that references a config object (approach 1) or maybe even references the config proxy directly (approach 2).  Let the music proxy have a similar property.

Presumably the config data, when loaded, is available via the config proxy.  With approach 2, the config data is therefore available to the animations proxy also, and ditto the music proxy.

If approach 1 applies, in the load completion process of config proxy, before sending notification that config has loaded
- retrieve a reference to the animations proxy and set the config-related property on it
- ditto the music proxy.

What do you think?
    Philip


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: trilec on March 28, 2008, 10:58:02
Im also trying to understand a multi preloading aspect for a Pure AS3 site.
Im looking at the  AppSkeleton PureMVC AS3 / Flex Demo
as Im trying to find a pureMVC way of doing this but sometimes converting the flex to pure AS3 is interesting when you dont know flex...lol

im not sure if its the same issue for you but have included what im using so far it case it can help
Ive edited it down for readability if there is a better method please let me know.
-------------------
Preloader swf loads
Preloader  loads assets,Background Anim and status
Preloader loads pureMVC app passing asset clips in vars
-------------------

preloader.as
:
package
{
 import flash.display.*;
 import flash.events.*;
 import flash.text.*;
 import flash.net.*;
 import flash.system.Capabilities;
 
 dynamic public class preloader extends MovieClip
    {
        public var ApplicationLoader:Loader;
        public var AssetLoader:Loader;
        public var status_clip:MovieClip;
        public var bg_clip:MovieClip;
        public var assets:MovieClip;
        public var application:MovieClip;

        public function preloader()
        {
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
bg_clip = new bg_asset();//located in preloaded fla has anim
bg_clip.init(Capabilities.screenResolutionX,Capabilities.screenResolutionY, {"animateOut":true, "onCompleteOut":transistionComplete} );
addChild(bg_clip);

status_clip = new status_asset(); //located in preloaded fla
status_clip.x =(stage.stageWidth/2)-(status_clip.width/2);
status_clip.y =(stage.stageHeight/2)-(status_clip.height/2);;
addChild(status_clip);
        }

        public function progressHandler(param1:ProgressEvent) : void
        {
            var percent:int;
            percent = Math.round(100 * (param1.bytesLoaded / param1.bytesTotal));
            var status_txt:String = "Percent " + percent + "%";
status_clip.drawText(status_txt);
        }

        public function transistionComplete() : void
        {
status_clip.drawText("LOADING STYLES");
AssetLoader = new Loader();
            AssetLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandlerAsset);
            AssetLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
            AssetLoader.load(new URLRequest("niceassets.swf") );
        }

        public function completeHandlerAsset(param1:Event) : void
        {
            assets = AssetLoader.content as MovieClip;
addChildAt(assets ,0);
            AssetLoader = null;
status_clip.drawText("LOADING APPLICATION");
ApplicationLoader = new Loader();
            ApplicationLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandlerApp);
            ApplicationLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
            ApplicationLoader.load(new URLRequest("pureMPCapplication.swf") );
        }

         public function completeHandlerApp(param1:Event) : void
        {
            removeChild(status_clip);
            status_clip=null;
            application = ApplicationLoader.content as MovieClip;
            addChildAt(application ,0);
            ApplicationLoader = null;
           //at this point pass prams to application including assets
           //application.init(assets);
        }
    }//class
}//package


t
 


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: dbasch on March 28, 2008, 04:24:19
Thanks for making the great tool. I have an issue with it though.

I am using the Startup Manager to monitor a Remote Proxy. Ideally, the remote proxy would perform different queries based upon the query type passed to it's search() function. However, this creates a problem because the load() function of the Startup Manager is called without any parameters. Therefore, I can't do this:

:
public function load(queryType) :void {
    this.search(queryType);
}

The only solution I have found is to set a queryType property on the Remote Proxy before registering it with the monitor.

:
remoteProxy.queryType = "customerQuery";

....register proxy with monitor..blah..blah...

public function load() :void {
    this.search();
}

public function search() :void {
    query(this.queryType);
}

Any suggestions on how to cope with this? Maybe load should accept some parameters?

Thanks,
Derek Basch


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on March 31, 2008, 02:42:19
trilec
Have you looked at the StartupManager Utility and the associated StartupAsOrdered Demo?  I know it maybe doesn't meet your needs, but I just want to be sure you've checked it out.
    Philip


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on March 31, 2008, 02:51:16
Derek
The difficulty with passing args to load() is that load() is called from within the startup manager and it doesn't have knowledge of the args.

The complexity of providing this knowldege to the manager, say through some additional property of the StartupResourceProxy, is hard to justify, when the app's own proxies can more easily provide themselves with the knowledge and can pass information between themselves as the loads progress.

Also, on reading your post, I wondered whether you are using the startup manager to monitor a single proxy?
    Philip



Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: trilec on March 31, 2008, 08:51:45
Thanks Philip,
Yes, I like the look of the startupmanager, but converting the example to as3 is a little new for me, Im still looking for a AS3 example of getting the startupmanager running even as code snips (Docs dont seem to give this). The ideal example would be 1 movie clip that the main app uses as assets and 1 xml that is a config, all using the startupmanager in a multicore pureMVC.

Two points I would like to clarify are:
Looks like you require a separate proxy for loading an asset ie. movieclip with style information (ie. background gradient clip,logo,some strange flying text thing) as this is not really a database more UI. This could get very confusing as a proxy would be holding UI component assets, perhaps I'm getting this confused after going through so much code examples...lol.

Also what would be the recommended procedure to trigger an introduction splash screen while loading other assets being once an style assets a loaded passing this information to the main application?

If anyone is interested I've started to reassemble with what little FLEX knowledge I have the startupmanager main timeline in AS3.
if anyone feels like helping, layout is not currect as i was just tring to get the main code in place.

//maintimeline application.as
:
package
{
import flash.display.MovieClip;
import fl.controls.ProgressBar;
import fl.controls.ProgressBarMode;
import fl.controls.Label;
import fl.controls.Button;
import flash.display.MovieClip;
import fl.controls.List;
import fl.data.DataProvider;
import app.startupasordered.ApplicationFacade; //test directory location

public class startupasordered extends MovieClip //main stage Clip
{
//private var Assets:MovieClip;
static public const NAME:String = "Application";

public var facade:ApplicationFacade;
public static const RETRY :String = "retry";
public var watchers:Array;
public var notifications:Array = new Array();

public var customerStatus :String = "";
public var productStatus :String = "";
public var salesOrderStatus :String = "";
public var debtorAccountStatus :String = "";
public var invoiceStatus :String = "";
public var overallStatus :String = "...";
public var retryIsVisible :Boolean = false;
public var retryIsEnabled :Boolean = false;

public var customerStatusLabel :Label;
public var productStatusLabel :Label;
public var salesOrderStatusLabel :Label;
public var debtorAccountStatusLabel :Label;
public var invoiceStatusLabel :Label;
public var overallStatusLabel :Label;
public var retryIsVisibleLabel :Boolean;

private var pb:ProgressBar;
private var retryBtn:Button;
public var notificationsList:List;
 
        public function startupasordered()
        {
facade = ApplicationFacade.getInstance();
notifications = new Array();
retryIsVisibleLabel = false;
createChildren();
creationComplete();

        }
        private function sendEvent( eventName :String ) :void {
dispatchEvent( new Event( eventName ));
        }
        public function creationComplete(param1:Event) : void
        {
            facade.startup(this);
            return;
        }

        private function createChildren( ) :void {
notificationsList = new List();
            notificationsList.dataProvider = new DataProvider(notifications);
            addChild(notificationsList);

pb = new ProgressBar();
pb.move(10, 10);
pb.mode = ProgressBarMode.MANUAL;
addChild(pb);

            retryBtn = new Button();
            retryBtn.move(10, 30);
            retryBtn.setSize(120, 20);
            retryBtn.label = RETRY;
            retryBtn.addEventListener(MouseEvent.CLICK, sendEvent);
            addChild(retryBtn);

customerStatusLabel=new Label();
            customerStatusLabel.move(10, 10);
            customerStatusLabel.text = "Customer Status: ";
            addChild(customerStatusLabel);

productStatusLabel=new Label();
            productStatusLabel.move(10, 10);
            productStatusLabel.text = "Product Status: ";
addChild(productStatusLabel);

salesOrderStatusLabel=new Label();
            salesOrderStatusLabel.move(10, 10);
            salesOrderStatusLabel.text = "Sales Order Status: ";
addChild(salesOrderStatusLabel);

debtorAccountStatusLabel=new Label();
            debtorAccountStatusLabel.move(10, 10);
            debtorAccountStatusLabel.text = "Debtor Account Status: ";
addChild(debtorAccountStatusLabel);

invoiceStatusLabel=new Label();
            invoiceStatusLabel.move(10, 10);
            invoiceStatusLabel.text = "Invoice Status: ";
addChild(invoiceStatusLabel);

overallStatusLabel=new Label();
            overallStatusLabel.move(10, 10);
            overallStatusLabel.text = "Overall Status: ";
addChild(overallStatusLabel);
        }
}//class
}//package



Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: kouri on April 01, 2008, 03:45:04
Philip,Cliff,

To set up a clean app skeleton, I understand that  it may be better now to study StartupAsOrdered (that implements StartupManager and  AsynchStub) than AppSkeleton.
Am I right ?

With spotlights on V2, many of us look like blind bats in a dark attic looking for best sample to bite
(juicy and bloody one ! :D) and as it's much easier to pick into manifold than reading all posts.. Would be great to get a small note on samples getting out of date. Just my point of view... ;)







Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on April 02, 2008, 02:41:54
Kouri
Just one small point in reply.  The StartupAsOrdered demo is narrowly focussed on demonstrating use of the StartupManager utiltity.  While it may be a useful reference, it is not intended to be a reference application for any real problem domain.
    Philip


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: puremvc on April 02, 2008, 08:24:52
Philip,

It might be nice, to get someone, anyone to study and come up with a little documentation for this extremely useful and important utility sometime. If you have time it would be most awesome since you know it best, but if anyone in these forums has a really good understanding, your contribution of some docs would be a great help. With all the ports and demos and utilities coming in, its getting super difficult for me to manage it all down to this level, though I'm trying...

Thanks,
-=Cliff>


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: justSteve on April 02, 2008, 12:12:00
I'd be in a position to to contribute some as I get a better understanding. In the interest of consolidating those handful threads that developed while the AppSkeleton morphed to include the StartupManagerProxy which is the foundation for the utility. I think part of documenting it would be greatly helped if someone with a deep knowledge of that process gave us a digested version of how things evolved the way they did and what precise hurdles it meant to solve.

I'd be happy to carry the ball another 10 yards or so on this project.

thx
--steve...


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: trilec on April 02, 2008, 06:21:34
Hi, Steve/Cliff
So True, still trying to grasp pattern concepts, have only just managed to complete a multicore prototype after spending three weeks just reading forums and source code... lol
I still find it a little ambiguous as to where one would use the startup manager (I was looking for it to fulfill the role of asset pre-loader)
and may be overkill for some development, but at which point?, and as I've posted before, means a proxy would contain GUI style elements or animation which views may need to build other GUI elements (styles manager proxy loading assets)? 
(hoping with a little more research/testing I will find where it fits my needs if any)

On a side note I feel the same for needing state machine utilities and implementation guidelines, there was some good discussion about this in previous state machines posts but seems to have become quiet.

Curtis [Trilec]


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on April 03, 2008, 04:06:01
Steve /Trilec /.../Cliff
Evolution of startup manager, as I recollect it
  • General Discussion forum, topic: "first project with puremvc", started by danieleUg
  • read through this forum, if you want to know the full story (in excruciating detail dare I say!)
  • I think Cliff coined the name StartupMonitorProxy
  • the problem to be addressed: a number of resources to be loaded at startup, using separate asynchronous requests, manage the loading in a structured way, with a design that would have general applicability
  • Daniele created the AppSkeleton demo and this evolved to a final version, with an important contribution from meekgeek along the way; the demo includes a resource dependency feature in that resources are sequenced and a resource can be marked as blocking the load of follow-on resources until that resource has been loaded
  • I needed a more generalised solution to dependencies between resources, and enhanced the code accordingly, within my application, and presented the revised set of core classes
  • as yet, there was no utility, these were applications with some common classes and common code fragments
  • Cliff was pushing for a utility, for ease of re-use, and I set about doing that
  • meanwhile meekgeek came in with some enhancements to cater for a timeout requirement that he had
  • I incorporated the timeout feature and then an associated retry feature and also catered for the case where a resource load fails; I also built in some robustness and proper separation of utility from application
  • this became the utility, with the StartupAsOrdered demo to illustrate use of the utility.   

When is the utility appropriate?  In my case, an application with accounting data, I wanted to load a variety of data at startup, using separate asynchronous requests, this data to then form an integrated object data model, so...
  • load in-progress accounting documents, but must have chart of accounts loaded first
  • chart of accounts requires that master currency info has been loaded
  • various kinds of reference information must be loaded before any of the above
  • and so on.
So, if you want to load an integrated data model, in separate chunks, then the utility could be useful.  You must look at your particular requirements and see if it has a role.

As regards documentation of the utility
  • see the API docs, available by viewing within the manifold project environment, or by asdoc from the src in the download zip
  • the demo app is key to understanding how to use it
  • my replies to some queries earlier in this thread may be useful
  • the source code of the utility is not large
  • Steve (and others), if you would like to contribute to the documentation, that would be great.

If there are people who have used the utility and have found it worthwhile, let us know here on this forum.  That would be a great way of seeing the kinds of problem that it is suited to.  Of course, let us know if you tried it and it failed to deliver - that would be important too.
    Philip


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: justSteve on April 03, 2008, 05:59:25
Many thankx for that Philip - great overview. This answers kouri's question regarding the relationship between the quote/unquote out of dateness of AppSkeleton. It's not so much that anything in AppSkeleton is deprecated by PureMVC v2 so much as that the technique used in the latest version of AppSkeleton has since been packaged into the StartupManager utility.

The 'StartupAsOrdered' demo illustrates the problem of monitoring the loading of dependent objects and less so the process of loading assets in the more conventional (media element) sense. Since I'm going to be working on asset loading handling very soon, I'll post a demo that focuses on managing a dynamic list of .swfs.

I'd suggest that AppSkeleton be updated to reflect the same functionality that it currently has but employs the StartupManager Utility so as to avoid kouri's understandable confusion.

Backing out to a big picture for a moment - Application startup being such a huge part of the process we are really lucky to have this utility. Philip's call for others' experiences with it bears amplification. If such information could be gleaned from server logs, it might be interesting to see what happens if an email could be generated to all users who've downloaded the utility asking that folks share their reactions.

Here's one of mine, wouldn't it be reasonable to build in the means of logging 'failure to loads'? Understanding that it's close to trivial to handle this at the given proxy - it sure seems that everyone interested in using the utility is going to be intensely interested in  logging failures.

I'm digging into the API docs to see if I can bring in some of the relevant info from this and previous threads in a useful way.

thx
--steve...


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: dbasch on April 03, 2008, 09:56:50
You asked for feedback on the usage of this great little tool so here it goes:

Here is my wish list:

  • I have been messing around, using this tool, for sequential data model loading after the initial startup sequence. I often find myself wishing that I could dynamically register resources with the same singleton monitor instance instead of having to instantiate a new singleton monitor repeatedly. I imagine the sequence would go something like this:
    • Check that the singleton monitor instance isLoadingFinished is true. This is currently a private attribute and listening for the LOADING_COMPLETE notification does not work within a command (createNewMonitor command for instance) as they don't listen for notifications.
    • Set the resourceList to empty
    • Dynamically register any new proxies that we may need
    • Call monitor.loadResources
    • You essentially do these same steps when you re-instantiate the monitor so why not cut some of the overhead?

  • I often wonder why the doRetryLoadResources() function doesn't start from the resource that is AFTER the last known properly loaded resource. The other resources have loaded properly so why do we get them again?

Thanks for the great tool and hopefully this was constructive  :)

Regards,
Derek Basch


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: puremvc on April 03, 2008, 10:34:11
Hi Derek,

Sounds reasonable. As with any open source project you are empowered to make it better!

How about checking out the trunk, making your suggested changes, test them in your app and then create a patch and post it here?

You could extend the existing demo or create another to show how it works.

-=Cliff>


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: dbasch on April 03, 2008, 10:38:50
Hi Derek,

Sounds reasonable. As with any open source project you are empowered to make it better!

How about checking out the trunk, making your suggested changes, test them in your app and then create a patch and post it here?

You could extend the existing demo or create another to show how it works.

-=Cliff>

Thanks for the reply Cliff. I will do what you suggested.

It appears that it is time for the StartupManager to become the ApplicationStateManager.

That is the way I am using it at least. But, I like to put round pegs in square holes  :P

Regards,
Derek Basch


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on April 03, 2008, 11:09:47
Derek
Just a few points in response to your above post, relevant if you are doing some work on this.

In the monitor, isLoadingFinished() does not test for complete, it just means this iteration is finished and the app has the option of retry.  allResourcesLoaded() would be appropriate test for completion.

retryLoadResources() does start a process that checks all resources but any that are already loaded are not re-loaded.

Good luck.
    Philip




Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: puremvc on April 04, 2008, 01:16:17
Derek,

I'm not sure ApplicationStateManager is the right name unless it's implementing the State pattern. Perhaps StartupManager is a misnomer if it's being used throughout runtime to load resources, but State management is a slightly different responsibility. Have a look at the threads on the State Machine Working Group http://forums.puremvc.org/index.php?board=25.0

I may have it wrong here, feel free to correct me with more info.

Cheers,
-=Cliff>


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: beavisnz on April 04, 2008, 02:34:52
Hi Philip / Cliff

Any chance of getting a retryAttempts function added to return the retry count??
i.e Application mediator can listen for LOADING_FINISHING_INCOMPLETE and retry X times before aborting.

:
/**
* Return number of retry attempts
*/
public function get retryAttempts():uint
{
    return retryCount;
}


Regards
Bevan


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on April 04, 2008, 03:05:42
Bevan
Fair point, we can add to todo list, for action at next opportunity - make retryCount accessible, per your suggestion.  Meanwhile, and in any case, you can maintain your own count in the app class that invokes retry, for example if it is occurring in a single mediator.

This is probably a good point to also mention Derek's comment about offering a controlled method for resetting the StartupMonitorProxy for reuse.
----Philip


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: puremvc on April 04, 2008, 04:00:20
I agree this should be handled by the utility. It would be nice if a retry policy could be set for each resource, (0, 1, 3, 5..). After the number of allowed retries has been exhausted, a fault would be thrown saying 'max retry attempts has been exceeded, try again' or similar.

-=Cliff>


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on April 04, 2008, 05:12:27
Cliff
Could you just clarify as to whether you mean that the utility would automatically invoke the retries?
----Philip


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: trilec on April 04, 2008, 06:24:38
Perhaps,
ProxyPreloadManager as opposed to  ViewStateManager (the next utility after this one :-) )

On a side note:
Do you think it will make much difference If I adjusted the startupmanager to use multicore so im not loading a single and multi versions into the app or
should startupmanager detect what you use and use that or
two versions with import adjusted or
your crazy Curt, just load the two and sit back down.

for reference:
:
package org.puremvc.as3.utilities.startupmanager.controller {
//import org.puremvc.as3.interfaces.ICommand;  //replace
import org.puremvc.as3.multicore.interfaces.ICommand; //exampe
etc ...

public class StartupResourceLoadedCommand extends SimpleCommand implements ICommand {
T



Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: puremvc on April 04, 2008, 08:23:59
Philip,

It would be nice to allow the utility to automatically invoke the retries. For instance, the demo inserts a button for the user to retry the download, but in a real app, the user shouldn't be forced to do this, nor should they care about what they're retrying the download of. If 3 of 5 downloads need to be retried a couple of times each, this would be annoying if manual intervention is required. So the system would just know how many times each resource can be retried before giving up and do it. Also, you'd want to specify a retry interval; how long to wait between retries.


-=Cliff>


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: puremvc on April 04, 2008, 08:29:44
Trilec,

At some point (when these latest features are working), it needs to be ported to MultiCore.

-=Cliff>


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on April 04, 2008, 11:35:20
Cliff
Yes, I agree about the utility carrying out the retries.

But note that the demo only has a retry button so that the developer using it can appreciate what is going on.  In a real app, with the existing utility, it is perfectly reasonable that the app would automatically decide whether to retry and how often to retry - no button for a real user.

----Philip


Title: Using Startup Manager to dynamically add resources.
Post by: justSteve on April 06, 2008, 07:49:13
Continuing the discussion of using the asset loading feature of Startup Manager to load assets at runtime....

I've refactored StartupAsOrdered so as to built a list of assets to load and am stuck on exactly how to insert them into the StartupMonitorProxy.

In a nutshell, I've created a proxy (AssetListProxy) that produces an array of strings intended to be the filename of swfs that need load management.
:
public function result( rpcEvent : Object ) : void
{
// call the StartupMonitorProxy to notify that the resource is loaded
sendLoadedNotification( ApplicationFacade.ASSETLIST_LOADED, NAME, SRNAME);
//parse the xml down to an array of swfs to load
mData = XmlResource.parse(data, rpcEvent.result);

//tosses error on reference to 'app'
sendNotification( ApplicationFacade.LOADASSETS, app );
}

I'm now attempting to call my LoadAssetsCommand where I intend to retrieve the array of swfs to load and create loop that will produce and register a StartupProxy for each in the list.

My problem is correctly referenceing 'app' in the call to my newly created LoadAssetsCommand.  Would appreciate any kickstarts. Project exported to FB3 archive at http://www.juststeve.com/StartupAssets.zip

thx


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: justSteve on April 06, 2008, 07:58:38
On the topic of documenting the Startup Manager....

I'm not sure if Cliff just missed Phillip's API documentation or what but, having reviewed that - I don't see how I can add much of value until/unless the utility actually takes on new tasks. Might be worth adding the historical overview from earlier in this thread but beyond that...great job!

Though perhaps Cliff was referencing documentation of the Demo itself.

--steve...



Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: puremvc on April 06, 2008, 08:09:10
I was referring not to the API doc, but to more of a 'theory of operation' type document. For instance, PureMVC has fairly complete API docs, but I doubt that would be enough to get across how you're actually supposed to use it.

-=Cliff>


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: trilec on April 06, 2008, 10:03:58
Hi Steve,
app = ApplicationFacade.getInstance(Application.NAME)  or am i missing something?

Curtis [Trilec]


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: puremvc on April 06, 2008, 10:18:56
No, that won' do it.

Only the ApplicationMediator will have a reference to the Application, as its viewComponent. And it won't be public. If you need something to interact with the Application, send a notification that the ApplicationMediator hears and let it do the work. In that respect the top-level Application is no different from any other view component in that you want to shield the rest of the PureMVC apparatus from knowledge of it.

-=Cliff>


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on April 10, 2008, 03:25:07
I am thinking that I should undertake some enhancements to the startup manager utitlity, arising from posts on this topic, as follows
  • a public method on StartupMonitorProxy, to reset it for reuse, controlled appropriately; i.e. we may want to use the utility more than once from our app, but not concurrently!
  • automatic retries, see Retry Policy below
  • but use sensible defaults, so that basic use of the utility remains as is.

These are refinements that 'round off' the existing set of features; I think it makes sense for me to do them.  If this conflicts with any work in progress by others, please let me know.

Retry Policy
I have done a little research into best practice.  My current thinking is...
  • policy, per startup resource, includes retry interval and max retries
  • automatic retry after load failure i.e. after the "load failed" notification from the app; the app knows what sort of failure occurred, it knows whether a retry makes sense or is futile, the "load failed" notification should include the facility for the app to state 'do not retry'
  • do not retry after timeout; so timeout is the limit on load time, inclusive of retry attempts; so timeout will result in finished_incomplete
  • this policy re timeout causes a complication; the full timeout cannot be used with each retry; the timeout must be decremented by the time elapsed for each try that fails 
  • if retries are exhausted or timeout has occurred, we have finished_incomplete and control returns to the app; let the app still have the option to invoke retry on the utility, to try again to load the failed resources; in this case we start again with max retries and full timeout available per failed resource.

Cliff, how does this seem to you?

Comments welcome of course.
----Philip


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: justSteve on April 10, 2008, 04:41:24
In the context of 'theory of operation' i think every thing starts from the fact that this utility grew out of an exploration of best practices for initializing a PureMVC application. Today's applications rely on certain resources having been loaded before real work can begin and 'resources' means more that a list of images (as was often the case in earlier ages).

So StartupManager helps implement the loading (and verification of load status) 'resources' required by a given application. Resources is loosely defined to include configuration settings as represented by AppSkeleton and successful completion of some 'processes' in some specific order as seen in StartupAsOrdered.

New users should understand that they need to add code that defines what those resources are, and what constitutes a successful load. The utility includes methods that allow us to define dependencies and retry/timeout properties. Users should not look to the utility to provide graphic 'pre-loader' status type display.

Since the utility is a fully 'PureMVC creature', studying how various demos implement different  processes will provide a better handle on PureMVC as a working framework. For example, looking at how a co-utility 'Asynchronous Stub' is used in StartupAsOrdered's delegate provides a powerful lesson in de-coupling dataprovers from a project while still delivering objects that fill-in until specfic backend data providers are needed.

>> Please consider the above thoughts to be a draft of 'theory of operation' overview and feel free to
>> specific other topics that need coverage or re-interpretation.

And now a request for some help with a demo that will show use of the utility to pre-load media (swf in this case) files where run-time code does not know the names of the files to be loaded.

I'm creating a pair of proxies that work together (each presumes the presence of the other) in a parent/child or ItemManager/Items relationship. AssetProxyList retrieves an xml file containing the names of SWF to be loaded. Upon successful load of that xml file AssetListProxy notifies the Startup Manager and fires the LoadAssetCommand which loops thru the list of assets creating a AssetProxy on each iteration.

The demo will run to completion without tossing an exception (which I count as a moral victory). However....it displays the message 'Loading Complete' after the AssetlistProxy has loaded but before the AssetProxy instances have started. Makes sense since prior to the loop that instantiate the Asset instances (the children) Startup Manager only knew about the ListProxy (parent).

Also, the Manager is generating a OutOfSynch message for each of the assets loaded ...even though it also generates those assets as successfully loaded. I think it has to do with how the Proxy registers itself - each iteration uses the same name for the StartupResourceProxy:

The constructor:
:
public function AssetProxy( swf2Load:String ):void {
NAME = swf2Load + "Proxy";
SRNAME = swf2Load + "SRProxy";

this.swf2Load = swf2Load;
super( NAME );

this.load();
}
then the load:
:
public function load() :void {
   
var delegate : LoadAssetDelegate = new LoadAssetDelegate(this, 'assets/' + swf2Load + '.swf', tempClipHolder );
delegate.load();
sendNotification( ApplicationFacade.ASSET_LOADING, swf2Load );
    this.monitor = facade.retrieveProxy( StartupMonitorProxy.NAME ) as StartupMonitorProxy;

// This var definition should probably be created with a dynamic name - How?
var rAsset :StartupResourceProxy = makeAndRegisterStartupResource( SRNAME , this.NAME as IStartupProxy);

}
   

Additionally, I'd like to start all the loaded clips in and ArrayCollection within AssetListProxy so other code knows where to find/play those clips.
So I include this code in the AssetListProxy:
:
public function add2ClipHolder( assetClip: MovieClip):void{
clipHolder.addItem(assetClip);
}

public function ClipHolder():ArrayCollection{
return clipHolder;
}
And attempt to gain access to that object from the AssetProxy but have so far failed to success. Any thoughts how to handle this?

Further...this arrangement of AssetList and Assets is obviously a common pattern where a Manager maintains info on an 'x' number of items. What features/corrections/refinements would my code need to be more formally in-line with that pattern?

thx
--steve...


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: justSteve on April 10, 2008, 04:47:53
http://juststeve.com/StartupAssets.zip


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: trilec on April 10, 2008, 05:21:35
Users should not look to the utility to provide graphic 'pre-loader' status type display.


why not?, seems most of the code is already in place to facilitate this, and would certainly add another dimension to an already nice utility.
This is also a very common problem that face pure AS3 coders.

On a side note:
if the startup manager is allowing reloading "using utility more than once from within an app"
perhaps appropriate notification would also be sent ".RELOADED", also tracking its reload of  n times. ?

T


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on April 10, 2008, 06:20:58
Steve
1. I noticed this, though you may be aware of it yourself...
var rAsset :StartupResourceProxy = makeAndRegisterStartupResource( SRNAME , this.NAME as IStartupProxy);
...the 2nd arg is a String, so can't be an IStartupProxy

2. In constructor to AssetProxy, why not pass in an asset counter, for example the i subscript of MData,  and use it to make the NAME and SRNAME unique?  As you say, for the utility, the IStartupProxy NAME must be unique.

Trilec
Have noted your side note.

----Philip


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: justSteve on April 10, 2008, 07:07:49
@ trilec - understood.  I'm trying to establish the point that the StartUpManager utility is not a simple pre-loader in the sense of graphic loading bar preloader we are used to using in Flash.


2. In constructor to AssetProxy, why not pass in an asset counter, for example the i subscript of MData,  and use it to make the NAME and SRNAME unique?  As you say, for the utility, the IStartupProxy NAME must be unique.

----Philip

Perhaps I'm not following.... NAME and SRNAME are already made unique by prepending the name of the asset to the strings 'Proxy' and 'SRProxy'. It's the var that store the return of the makeAndRegisterStartupResource command that (i think) needs to be addressed.

thkx much for the time
--steve...


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: puremvc on April 10, 2008, 08:23:25
I agree that adding a preloader functionality would be nice. I wonder if it should be decoupled from the StartupManager but used by it. Like the AsyncStub. Would this make sense?

-=Cliff>


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on April 10, 2008, 08:50:36
.... NAME and SRNAME are already made unique by prepending the name
Yeah, I see that Steve - sorry for mis-reading it.  And well done for drafting a 'theory of operation'.  ----Philip


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: justSteve on April 10, 2008, 02:14:28
Still stumped by how to dynamically name a StartupResourceProxy. In pre-AS3 days i'd do something like:
 
   var this["rAsset" + swf2Load] :StartupResourceProxy = makeAndRegisterStartupResource( SRNAME , this);

That seems not to be an option anymore.

thx


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: jowie on April 18, 2008, 09:00:04
Hi Philip,

Apologies for the delay in replying- I never had a subscription email so I didn't realise anyone had replied!  :o

Let the animations proxy have a property that references a config object (approach 1) or maybe even references the config proxy directly (approach 2).  Let the music proxy have a similar property.
But I thought in PureMVC you were not allowed to communicate directly between proxies? Did you mean I should pass in the instance of the configProxy to both proxies when they are initialised? Is this allowed?

Thanks for your help!  :)


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: puremvc on April 18, 2008, 09:36:44
There's no problem with a Proxy retrieving and interacting with another Proxy. The Proxies are able to encapsulate dependencies in the Domain Model this way.

So a Proxy could retrieve another Proxy, and set or get properties and call methods. What you don't want to do is have a Proxy retrieve a Mediator and interact with it in any way. That coupling is not good. The Model should have no knowledge of the View. This lets the same Model be reused in multiple applications with different Views and use cases.

By having the Model internally aware of different parts of itself, we're not encouraging a bad coupling. We might otherwise be tempted to push the Domain Logic that keeps the integrity of the Model into Commands, where Business Logic lives. If we try and reuse our Model and it requires a bunch of Commands to be present and registered then the Proxies are making a lot of assumptions about the application they're loaded into. Packaged separately, a Proxy could easily be allowed know the names of the other Proxies it collaborates with to maintain integrity in the Model.

-=Cliff>


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: puremvc on April 18, 2008, 10:04:31
Philip,

Regarding your Retry Policy thinking above, it all sounds great. The parameters of the problem are pretty well thought out, and I'm sure the changes will be executed in the most usable way.

-=Cliff>


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: cmosretina on April 19, 2008, 07:32:16
Hi,

I just wanted to point out a tiny glitch I stumbled upon while going through the source code of the StartupManager utility...

At line 178 of the class StartupMonitorProxy.as, there's the following error-handling statement:

:
if ( proxy == null ) throw Error( proxy.getProxyName() + ISTARTUP_PROXY_MSG );

If ever executed, the preceding code would produce a TypeError: Error #1009, since proxy is not initialized.

The solution would be to replace proxy with r as in the following snippet:

:
if ( proxy == null ) throw Error( r.getProxyName() + ISTARTUP_PROXY_MSG );

This should work fine, as r refers to an instance of StartupResourceProxy that is most certainly instantiated.

Hope this helps.

And thanks for the great framework!


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on April 21, 2008, 03:13:48
Hi,

I just wanted to point out a tiny glitch I stumbled upon while going through the source code of the StartupManager utility...

Thanks for pointing this out.  It will be corrected at the next opportunity.  It may be that this error check is redundant, since the app resource proxy must have implemented IStartupProxy to even get accepted at instantiation of the StartupResourceProxy.  I know that this error check originated at a time when the utility was in development, pre-release, and the StartupResourceProxy did not exist in its current form.
----Philip


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: justSteve on April 21, 2008, 07:13:10
I've made some progress with the dynamic asset loader sample - things correctly load when the called clip is present and correctly ioError when not present. My current problem boils down to the correct way to let the Startup Manager know that the process is complete.

Reviewing....I have concrete proxy called AssetManagerProxy that loads an xml list which declares what SWFs will be loaded. It's result handler triggers a command that dynamically instantiates an AssetProxy for each item on that list. If my AssetManagerProxy fires it's sendLoadedNotification at the point that it actually loads (as found in the StartupAsOrdered demo) none of the AssetProxies have yet been created and I end up with smCallOutOfSynchIgnored messages.

Deferring the sendLoadedNotification will eliminate the smCallOutOfSynchIgnored messages but cause other problems. Current code at juststeve.com/StartupAssets.zip

many thankx


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on April 22, 2008, 03:56:09
Steve, regarding your StartupAssets...
I have looked at your code, selectively.  This reply is with the hope of being helpful, but I acknowledge that I do not have practical experience with dynamic asset loading.  If I have misread your code or misunderstood the requirement, please forgive.

You depart quite a bit from the normal use of the startup manager, knowingly I'm sure, to try to achieve your goal, for example
  • AssetProxy invokes its own load(), and I suppose expects that the monitor will not
  • in AssetProxy, swf2Load is a String but is used also as type IStartupProxy.

In my opinion, the standard startup manager view of your requirement would be
  • use it once to do the first load via AssetManagerProxy, let that complete; I suppose you don't even need it for this single resource load
  • on completion of the first load, use it again, a new instance, to load the set of assets; these seem to be all known at that point; orchestrate it via the LoadAssetsCommand i.e. let it create the startup resources, set dependencies if any, and invoke loadResources(); let the utility invoke the load() operations in the normal way.

For the StartupManager to truly address dynamic loading, we would maybe need features like
  • tell it that resources will be added dynamically, so that it holds back on announcing completion
  • on dynamic addition of a resource, it re-invokes loadResources
  • tell it when all resources have been added.

----Philip


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: justSteve on April 23, 2008, 07:19:05
Thx much for the review and comments. I'm going to have a look to to see if things work better if the AssetManagerProxy is just a plain old proxy instead of typing to a Startup manager - or otherwise establish the list of assets to import prior to invoking 'loadResources'.

Don't be too sure about my 'knowingly-ness'. I'm inclined to live with stupid code if they work or even seem to. I understand that attitude might disqualify me from communion with those of more pure motivations so I'm trying to upgrade my skills and raise my standards. ;)

So:
in AssetProxy, swf2Load is a String but is used also as type IStartupProxy.

falls into that category. Since I need swf2Load to be a string at one point and a of type IStartupProxy at another, what would be a more correct approach?

As to the bigger picture of accommodating dynamic assets, I think I'm fairly close to meeting my own short-term purposes so I probably won't be agitating for more attention to this issue unless/until someone else needs something along these lines.

That said...I still think management and monitoring (logging) of issues pertaining to application startup deserve more attention.

again...thankx for your time
--steve...


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: jowie on May 08, 2008, 10:10:30
There's no problem with a Proxy retrieving and interacting with another Proxy. The Proxies are able to encapsulate dependencies in the Domain Model this way.
That's good to know... Thanks Cliff! :)


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: chaocai on June 06, 2008, 05:40:12
Hi, I am pretty newbie, gotta a question...seems

LOAD_RESOURCES_REJECTED from pureMVC\Utility_AS3_StartupManager\trunk\bin\Utility_AS3_StartupManager_1_3.swc was missing?

I got Access of possibly undefined property LOAD_RESOURCES_REJECTED through a reference with static type Class. error, but was compiled and worked fine when I used Utility_AS3_StartupManager_1_2.swc


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on June 09, 2008, 03:03:52
Your problem has arisen because you have taken the startup manager swc from trunk/bin.  This is a new version of StartupManager.  It has not been tagged for official release yet.  See the version.txt file for the steps required to migrate from version 1.2 to this later version.

There is quite a bit of new functionality in this version. and though trying to keep migration steps to a minimum, nevertheless, for a better base going forward, some steps are required.  One step is: remove LOAD_RESOURCES_REJECTED from notification interests and handling.

There is a new release of the StartupAsOrdered demo, updated for this new StartupManager.
----Philip


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on June 10, 2008, 02:56:01
Cliff has "bagged and tagged" the new version (1.3) of StartupManager, so it is now officially available.  The objective has been to address some of the concerns and desires expressed here in the forum.

For convenience, here is the standard link to the utility
http://trac.puremvc.org/Utility_AS3_StartupManager (http://trac.puremvc.org/Utility_AS3_StartupManager)

On that page, see the Release Notes link.

There is a reset feature, to facilitate reuse of StartupMonitorProxy. There is a facility for automatic retries.  Timeout is still there but has a different interpretation in the context of retries.  The idea of dynamic resources has been addressed as an open-ended resource list.

The StartupAsOrdered demo has been enhanced to illustrate use of some of these features - version 1.5 of the demo.
 
I hope this new functionality is of use to some of you.
----Philip



Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: meekgeek on June 12, 2008, 10:48:38
 :)

Hey, it's been a long time since I've posted anything on this forum. I apologize if I'm just reiterating something that's already been said.

I just have a quick question..

Looking through this topic I've noticed some talk of asset managing. 
I love this manager.  It's great for setting up your backend, streaming, and xml connections at startup but if I want to load up another swf at runtime I feel that this manager shouldn't be in charge of it.  It's great right now!

I do however need a manager for loading one or multiple swfs.  I realize this tool is probably more geared toward a flash site where you don't need all the pages loaded at startup, just the ones the user wants to see.  It would be great if you could make a list of swfs then, have as3 use the URLStream class to just find the totalbytes of everything in your list(without loading), then begin loading with a proper progress event handler that gives you an accurate percentage of all the swf's, flv's, or images in the list.

I know justSteve has been working on something similar.  Should this constitute another utility?  Anybody else see a need for this?  Am I talking out of my butt?


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: puremvc on June 13, 2008, 07:00:18
Sounds like it could be another utility. But before muddying this thread with how it would work, perhaps a little elaboration on why you don't think startup manager is right for the job, and why it wouldn't be more appropriate to just extend it?

I'm ok with a new utility if folks think its warranted.

-=Cliff>


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: justSteve on June 13, 2008, 08:13:19
I know justSteve has been working on something similar.

Funny...you misspelled 'mangling'. ;) ...actually, more like 'advocating for'  But make sure you are looking at the most recent version of StartupManager - the recent update references:

Added support for open-ended resource list.

Lately I've been grasping @ Pipes and am only just now getting enough time to take a look at it. Some time on it this weekend or bust. But speaking of pipes and 'other utilities' brings to mind the idea of a 'pipe aware' (or would that be multi-core aware) StartupManager to help with transModule management of Loading and starting up multi-core apps.

--steve...


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: meekgeek on June 13, 2008, 11:09:10
perhaps a little elaboration on why you don't think startup manager is right for the job

Maybe it's just the way I've grown to use it.  For me, it's the step before I setup my view, and there on end, call it when ever the view changes something in the model.

The utility that I'm proposing gives you the ability to load more "viewComponents."  You would have the ability to start and stop a load, load multipy files. Maybe even have it be aware of what type of file it's loading.  Factory pattern comes to mind... something with keys so you can refrence an image by name, if it finds it return Bitmap, if not load and return.

And just to simplify things, have startupmanager be a utility used for the model layer, and this new one for the view. 

If you disagree, let me know why.  I want to learn...

Mold me Cliff  ;D  into a mvc genius like you


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: puremvc on June 13, 2008, 02:36:43
The biggest reason I would lobby for extending StartupManager is all the loading stuff could be handled by one contraption and not two. It doesn't seem much of a stretch.

I am just asking whether there is some basic conceptual incompatibilty with StartupManager or if there is a way to extend it gracefully to handle the assets for the view.

anybody else out there have feelings about this? Chime in now! :)

-=Cliff> 


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: meekgeek on June 16, 2008, 10:00:40
I guess I'll experiment with both routes :)


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on June 16, 2008, 10:12:02
The startup manager (sm) , as use of it has evolved, can be used at any time, not just at startup, and is not necessarily particular to the model layer.  The internals have nothing specific to the model layer, it seems to me.

The choice of resource type arises within the client app, with the app's proxy, which must implement IStartupProxy and that is simply a load method.  This is the area which could be analysed so that common requirements could be bundled into a separate utility, which would in turn use the sm utility, or could be met by an enhanced sm utility if that made sense.  If this is the area that needs attention, it seems a shame to discount use of the sm as a body of core fucntionality.

You would have the ability to start and stop a load, load multipy files. Maybe even have it be aware of what type of file it's loading.  Factory pattern comes to mind... something with keys so you can refrence an image by name, if it finds it return Bitmap, if not load and return.

Taking the above quoted points, and interpreting them as logically inside or outside the existing sm
- start and stop a load: outside, local to the client app proxy; is it critical that the overall monitor be able to do this?  what is the example case?
- multiple files: inside, existing sm functionality
- be aware of file type: outside, local to the app proxy; again does the overall monitor need this awareness?
- factory pattern...if it finds...if not...: outside, local to the app proxy, the load method can have this lookup logic and can send a loaded notification if the resource is already loaded.

I think we need greater detail on the example case, so that we can see where the sm is deficient - is it in the core functionality or is it in the peripheral functionality?

----Philip


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: meekgeek on June 16, 2008, 09:15:18
I'm probably just speaking for myself. My needs might be very unique but perhaps your right and I might be able to use StartupManager.

start and stop a load: outside, local to the client app proxy; is it critical that the overall monitor be able to do this?  what is the example case?

Lets say I'm trying to load two files of similar size that will take 20 seconds to complete.  The current manager will take the percentage to 50% at 10 seconds and then go to 100% at 20.  Seems two long a wait for no action to take place.  That's why a contentmanager that can initialize to calculate the totatlbytes of the two files and then give you an accurate percentage rate before you actually start loading is crucial for sites that need to load a video or swf of that caliber.

As far as the rest of it goes, you're right...

Although, I am going to try something new with what i'm experimenting with right now.  The manager I'm building has a public load method that accepts a request object which contain a callback function and a list of assets to load.  Once loaded I'm going to try and send back an object with a keys tied to the asset it loaded.  for example:

:
key = "my.jpg"
object[key] = bitmap

Hope I'm making sense.  Anyway.  I'll see how this works for me and once done, I'll see if I can do the same with the current StartupMonitor.  If I can live with just using the StartupMonitor I'll post my findings.


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on June 17, 2008, 04:21:33
For what it's worth, here are my thoughts regarding the file sizes requirement, if trying to extend the startup manager
- the sendProgressNotification() method, should be protected access rather than private, to enable override [ should have been protected access anyway!!!  :( ]
- StartupResourceProxy to have new properties such as 'number of bytes' and 'load rate'
- ResourceList (IResourceList) to have getters for such as 'expected total number of bytes to be loaded', 'number of bytes loaded', 'average load rate', 'load start time', 'expected load completion time'
- then sendProgressNotification() might be able to send the required progress information
- time-based sending of the progress notification, as well as on completion of each resource load.

Better still, encapsulate all the progress percentage calculation within ResourceList, with a single getter 'percentage complete' that sendProgressNotification() can use.
----Philip


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on July 20, 2008, 07:45:36
StartupManager MultiCore ...
For the 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.
----Philip


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: puremvc on September 06, 2008, 01:41:47
StartupManager Version 1.4 is tagged and available now. See the release notes for more info:
http://trac.puremvc.org/Utility_AS3_StartupManager/wiki/ReleaseNotes

-=Cliff>


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: marek on September 26, 2008, 04:35:45
I tried to use StartupManager with swc files downloaded directly from SVN. Works fine. However if I'm using it with original source code included into packages got a problem with:
:
_monitor.defaultTimeout = 30; - sets in StartupCommand from example
:
StartupMonitorProxy.LOAD_RESOURCES_REJECTED - from StageMediator

Could you guys please check final 1.4 tag on SVN and just make sure that AS3 code = .swc files?


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on September 29, 2008, 03:05:38
StartupManager (SM) utility does not have a StartupCommand and does not have a mediator.

Maybe you are referring to the StartupAsOrdered demo.  StartupAsOrdered needs to be version 1.5 to be compatible with SM version 1.3 or later.  The code fragments you quote look like they're from an old version of StartupAsOrdered.

Hope this helps.
----Philip


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on October 21, 2008, 02:51:04
With reference to the assetloader feature of StartupManager, the question of urls ending with .css arose on  the StartupForAssets thread.  In order to ensure the maximum possible feedback on this, I am asking the general question here, this being the appropriate place anyway.

The currently supported set of types in the AssetFactory urlToType method, based on url name endings, are
- image type: .jpg, .gif, .png
- text type: .txt, .xml
- swf type: .swf

Apart from including .css as a text type, what other types should I include?

Also, do people think it would be better to have the logic default to text type when the ending is unrecognised, as opposed to the current approach which is to throw an error?

----Philip



Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: Jason MacDonald on October 29, 2008, 10:02:24
So I've been trying to be diligent in my app and clean up any unused Proxy's and Mediators and noticed that, despite removing a couple Proxy's that were used with StartupManager, I have a bunch of NAMEProxySR's still being referenced in my Facade.model.proxyMap. Does StartupManager not cleanup these files after it completes? I can clean them up myself but was wondering if there's a reason for leaving these references after the start-up utility has finished and is no longer needed?


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on October 30, 2008, 03:41:05
@jasonmac
Some points by way of reply...
1. In general, I take your point; I'm sure the SM could do better in this regard; I will review it for the next release; any specific suggestions are welcome

2. Where the client app creates and registers a proxy, then it seems reasonable that the app is responsible for cleaning it up; but the SM should ensure it is not retaining references that prevent the gc from doing its job

3. Currently, use of the StartupMonitorProxy reset() method, does go some way towards removing references that relate to the previous session; you could use this even if you are not going to re-use the SM; you could even instantiate a new StartupMonitorProxy as a way of losing previous references

4. On loading complete, it could be argued that SM state still needs to be retained, in case the client app want to interrogate it; so probably we need a new method call by which the app can tell the SM to clear its state.

----Philip


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: Jason MacDonald on October 30, 2008, 06:00:25
Thanks for the reply philip. I ened up adding a simple public function to StartupMonitorProxy called Cleanup();

:
public function cleanup():void {
     if(!loadingActive) {
         for each(var resource:StartupResourceProxy in loadedResources) {
facade.removeProxy(resource.getProxyName());
         }
         // might want to add cleaning of failed files? Though apps usually won't load if things failed
    }
}

I didn't mean to imply there was anything wrong with leaving it up to the developer to clean up these files, but was more curious if there was a reason they needed to be left in. THanks again for your great utility!


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on October 30, 2008, 07:43:58
Jason, thanks for sharing your cleanup() code.  I'll do something on this in the next release.
----Philip 


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on November 21, 2008, 03:35:57
The 'Startup Manager / API Docs' link in the manifold project is not right - it refers to an old version.  Until this is corrected, to see the correct api docs, make sure you use the download.
----Philip


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on November 24, 2008, 07:45:16
The 'Startup Manager / API Docs' link in the manifold project IS NOW CORRECT, thanks to Cliff.
----Philip



Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on January 16, 2009, 04:47:10
There is a new version of StartupManager in the code repository; in trunk, not tagged.

The enhancements are minor.  Here is extract from version.txt.

1.6 This release is backward compatible.
    Within asset loader feature, in AssetFactory class: support for
    .css urls as asset type Text, plus defaulting to type Text,
    hence reduced likelihood of 'unexpected url type' as an Error
    condition.
    Within StartupMonitorProxy class: new cleanup method, to remove
    StartupResourceProxy objects from proxy map; also, the reset
    method now includes this cleanup of SRP objects.

So, note that monitor.reset() now does a facade.removeProxy for SRP objects.  If this is a problem for anybody, please let me know.
----Philip
 


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: dbasch on January 16, 2009, 09:51:13
So, note that monitor.reset() now does a facade.removeProxy for SRP objects.  If this is a problem for anybody, please let me know.

I believe this is the correct behavior. I was manually removing them before.

Thanks,
Derek Basch


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: zerozero on February 10, 2009, 04:11:08
Hi there,
I've been noodling around with the startupManager utility for a pure actionscript, multicore project and I've come across an issue I'd like to run by the forum:

I plugged the startupManager and all dependent libraries into my project (hacked the mx.core classes in just so it would run for the time being.. more on that later). When I run it I am getting an Error: multitonKey for this Notifier not yet initialized! at StartupResourceProxy/get monitor(). Stepping through the debugger I find that this is because the StartupResourceProxy for each resource isn't being registerProxied. The API docs say:

This method offers an alternative to that, as a shortcut for the client app, whereby the app does not have to create the StartupResourceProxy (sup) object for the IStartupProxy object. Instead, the StartupManager (SM) will create the sup object. But note that the app does not then have a reference to it and has not given it a name and has not registered it using registerProxy(). In fact, the SM will not give it a name and hence will not register it. This is fine as regards the SM operations.

I wonder if this is maybe true only for the AS3 Standard version because here in the Multicore version it seems to be necessary to register the proxy in order that the StartupResourceProxy can retrieve the facade in it's get monitor() method.

What I have ended up doing is registering the proxy using the url for the resource as a unique name:

:
public function addResourceViaStartupProxy( px :IStartupProxy ) :void {
var name : String = ( px as AssetProxy ).url ;
        facade.registerProxy( new StartupResourceProxy( name, px ) );
var r :StartupResourceProxy = facade.retrieveProxy( name ) as StartupResourceProxy;
        //var r :StartupResourceProxy = new StartupResourceProxy( "", px );
addResource( r );
}

Which seems to work. I'm just wondering if there is another way around this, or if I'm making some fundamental error or whether I am just the first person to notice this behaviour. Anyway would be interested in any thoughts.

Jon


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on February 11, 2009, 03:44:10
You are right it seems to me.  For a proxy to be viable in multicore, at least as regards using the facade var, the proxy must be registered.  A comparison of Notifier.as in standard and multicore shows this.

This means that the method addResourceViaStartupProxy(), of StartupMonitorProxy, is not valid in multicore.  Instead the addResource() method should be used, and the client app should register the StartupResourceProxy before passing it to addResource.

The addResourceViaStartupProxy method was introduced in version 1.4, as an alternatve to addResource().  In the assetloader feature, the LoadAssetGroupCommand uses this method and hence that command is also not valid for multicore.

I am sorry this problem was not identified by me pre-release.  I will deal with it in the next release.  In the meantime, for users of the LoadAssetGroupCommand, workaround options include
- extend StartupMonitorProxy and override the addResourceViaStartupProxy method
- or extend LoadAssetGroupCommand and override the prepAssetGroupForLoad method.

----Philip


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on March 02, 2009, 08:37:41
Arising from the previous 2 posts, there is a new version of StartupManager in the code repository; in trunk, not tagged.

Here is extract from version.txt.

1.6.1 This release is backward compatible.
      Method addResourceViaStartupProxy() of StartupMonitorProxy
      now registers the new StartupResourceProxy objects.

By way of further description, here is an extract of relevant code
:
        /**
         *  See addResource() above.  This method offers an alternative to that, as a shortcut for the
         *  client app, whereby the app does not have to create the StartupResourceProxy (srp) object for the
         *  IStartupProxy object.  Instead, the StartupManager (SM) will create and register the srp object,
         *  naming it as follows
         *  <ul><li>
         *  use the name supplied as the second, optional argument; if supplied</li>
         *  <li>otherwise, create a name by prefixing a suitable string to the name of the given
         *  IStartupProxy object; the prefix is specified in the var <code>prefixIfAutoSRPName</code>, which
         *  has an initial value that should usually suffice for uniqueness
         *  i.e. const StartupManager.PREFIX_IF_AUTO_SRP_NAME i.e. "smSR_"</li>
         *  </ul>
         *  This shortcut is probably attractive only if there are no dependencies between the resources,
         *  because the app requires references to the srp objects, to express the dependencies.
         */
public function addResourceViaStartupProxy( px :IStartupProxy, resourceProxyName :String = null ) :void {

----Philip


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: puremvc on March 02, 2009, 12:12:15
Hi Philip,

Will bag 'n tag this release soon. Send me an email so I can put it in the queue.

Also, on the subject of retry policies which SM deals with, I came across this entry in the Amazon SimpleDB service glossary which I thought was brilliant:

exponential backoff

    A strategy for reducing the load on the system and increasing the likelihood of repeated requests succeeding by incrementally decreasing the rate at which retries are executed. For example, client applications might wait up to 400 milliseconds before attempting the first retry, up to 1600 milliseconds before the second, up to 6400 milliseconds (6.4 seconds) before the third, and so on.

It might be easy to implement a Boolean expBackoff parameter to RetryPolicy/RetryParameters to so that if true, the retryInterval is the initial interval, and subsequent retries are exponential values of that.

Just a thought.

Rock on,
-=Cliff>


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on March 04, 2009, 02:32:44
Cliff, exponential backoff idea, duly noted.
----Philip


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: flib on March 12, 2009, 07:55:21
Hi guys,

I'm looking into the startup manager and its asset loader.  My app is very sound orientated. 

Any chance that support for mp3s could be added to the next release?

Also, is the asset loader intended to work in flash? Just, I noticed references to flex components in the assetloader/model/assets folder.

Thanks


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on March 16, 2009, 05:12:32
Any chance that support for mp3s could be added to the next release?
Could you help with some information?  This would be a new type of asset.  As a loader, do we have to use flash.media.Sound, rather than Loader or URLLoader? If we have a new asset class, say AssetOfTypeSound, and if it implements IAssetForFlex, what kind of UIComponent would be appropriate?

Also, is the asset loader intended to work in flash?
There are 2 interfaces available for assets: IAsset and IAssetForFlex.  The 3 supplied asset classes implement IAssetForFlex.  If you want to avoid IAssetForFlex, you could use your own asset classes to extend AssetBase and implement just IAsset.  If you do this, it would be great to let us know here on the forum.

Thanks
----Philip


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: Helmut Granda on March 26, 2009, 12:44:06
Hi,

Is there any reason why this code:
:
import mx.collections.ListCollectionView;

    import org.puremvc.as3.utilities.startupmanager.model.RetryParameters;
    import org.puremvc.as3.demos.flex.startupasordered.ApplicationFacade;

    private var facade:ApplicationFacade = ApplicationFacade.getInstance();

    public static const RETRY :String = "retry";
    public static const LOAD :String = "load";
    public static const TRY_TO_COMPLETE :String = "tryToComplete";

    [Bindable] public var customerStatus :String = "";
    [Bindable] public var productStatus :String = "";
    [Bindable] public var salesOrderStatus :String = "";
    [Bindable] public var debtorAccountStatus :String = "";
    [Bindable] public var invoiceStatus :String = "";
    [Bindable] public var overallStatus :String = "...";

    [Bindable] public var notifications :ListCollectionView;
    [Bindable] public var retryIsVisible :Boolean = false;
    [Bindable] public var retryIsEnabled :Boolean = false;

    public var retryParameters :RetryParameters = new RetryParameters();
    [Bindable] public var paramsEntryIsEnabled :Boolean = true;
    [Bindable] public var mode :int =1;

    [Bindable] private var initialMaxRetries :int = retryParameters.maxRetries;
    [Bindable] private var initialRetryInterval :Number = retryParameters.retryInterval;
    [Bindable] private var initialTimeout :Number = retryParameters.timeout;

    private function goLoad() :void {
        updateRetryParameters();
        if (mode == 1)
            sendEvent( LOAD );
        else
            sendEvent( TRY_TO_COMPLETE );       
    }
    private function sendEvent( eventName :String ) :void {
        dispatchEvent( new Event( eventName ));
    }
    private function updateRetryParameters() :void {
        retryParameters = new RetryParameters( maxRetries.value, retryInterval.value, timeout.value );
    }

is placed inside the MXML document rather than in the ApplicationFacade? I am asking this because I am working on a flash application (not Flex) and I use Main.as as my main entry point to the application and ApplicationFacade as the entry point to PureMVC and I'm not sure in this case where exactly the events and properties should be moved into.


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: puremvc on March 26, 2009, 04:13:55
None of this is a responsibility of the facade. A read of the Framework Overview and Best Practices docs will he'll sort out the responsibilities of the framework actors. The examples are in Flex but that is really irrelevant with regard to the roles of the framework classes.

-=Cliff>


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on April 28, 2009, 05:22:47
I want to discuss an enhancement to the SM utility.
Objective
Cater for concurrent instances of StartupMonitorProxy. For general use, this would be more natural. In addition, there are specific types of use that this enhancement would facilitate, for example
  • have a long running instance for loading assets on demand, using the keepResourceListOpen feature
  • create another instance to load some data resources and then, when finished, cleanup and remove reference to it
  • create another instance to load some specific assets blah blah blah.
  • create another instance blah blah blah.
In relation to this example use, see this forum entry
http://forums.puremvc.org/index.php?topic=258.msg4477#msg4477

Preamble to solution
  • the sm commands, StartupResourceLoadedCommand and StartupResourceFailedCommand, must be able to select the correct sm instance when processing the loaded/failed notifications from a client app
  • would like to maintain backward compatibility, so that existing apps will run correctly with this (proposed) new version of sm, for example, notifications sent by sm currently include jobId as notification type and some apps maybe use this feature.

Solution
  • StartupMonitorProxy (smpx) constructor takes proxy name as optional arg
  • disallow setting of jobId when smpx name is not the default, i.e. when not StartupMonitorProxy.NAME; so, jobId is retained for old usage but is not supported for new usage; it is considered redundant when each "job" can have its own sm instance
  • the notification type, on notifications sent by sm, is the smpx name, unless there is a jobId in which case the notification type is the jobId as at present
  • the contract between the sm and the client app is
    • sm guarantees to send notifications with type smpx name unless there is a jobId
    • client guarantees to send the resource loaded/failed notifications with type as smpx name if the smpx name is not the default; thus the sm commands will be able to select the correct sm instance based on the notification type.

Notes
  • the choice of smpx name as notification type, rather than a reference to the smpx instance, facilitates the following usage idiom: a smpx and a progress mediator can be instantiated as a pair, with the same name, enabling name comparison as the selection condition for notifications to be handled in the mediator.

So, any comments? .../ yes it's worth doing / no don't bother / the approach is wrong / ...
----Philip


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: puremvc on April 28, 2009, 09:28:18
Makes sense to me.

-=Cliff>


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on July 12, 2009, 04:47:24
There is a new version of StartupManager in the code repository; in trunk, not tagged.

It has been numbered as version 2.0, since it is a significant enhancement.  Here is the relevant extract from version.txt.

2.0 This release is backward compatible, except for users who have
    implemented their own IResourceList or IRetryParameters (see
    below).
    StartupMonitorProxy (monitor) constructor now takes proxyName
    as an arg (optional), thus enabling concurrent instances.
    Property jobId is disallowed unless the monitor proxyName is
    the default name.
    On sent notifications, the type is the monitor proxyName,
    unless there is a jobId, in which case the type is the jobId
    as it has been since version 1.4.
    On loaded and failed notifications sent by the client app, if
    the monitor proxyName is not the default name, the notification
    type must be the monitor proxyName.
    IResourceList methods addResource and addResources have a
    changed signature, to include an arg that references the
    monitor instance. Existing usage that passes an IResourceList as
    the data arg to the monitor constructor must change to (null,data)
    since data is now the second optional arg, proxyName being the
    first. IResourceList has new method isToBeKeptOpen.
    IRetryParameters has a new parameter, to switch on exponential
    backoff logic when RetryPolicy applies the retry interval.
    Users of the assetLoader facility, note the following:
    - LoadAssetGroupCommand and LoadingInstructions have been
    frozen in their pre-v2 state, and will not be updated; retained
    only to maintain backward compatibility
    - new version of StartupForAssets demo (version 2).

Note also that, though this utility is named Startup Manager, a more appropriate name might be Resource Loading Manager, since it can be used at any time, not just at application startup.


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: puremvc on July 13, 2009, 10:05:45
Philip,

I agree on the naming of the utility having become less than accurate if not downright misleading. Startup isn't completely a resource-loading-centric process, that's just a step in the overall process. There is also an alliterative conflict with the StateMachine utility name.

I'd like to propose that we branch the codebase, leaving 1.x on a branch, and from 2.0, refactor to a new name. If we're ever going to resolve this, now's a good enough time. Especially since I see you're deprecating some stuff this time. You could drop the baggage that's being carried along for backward compatibility (making the library smaller and less scary to users trying to learn it. :)

Any feedback on naming would be good. The shorter the better.

One thing I realize as I try to think of a suggestion for a less cumbersome name than Resource Loading Manager is that the thing has evolved quite a bit from the start. As a result there is no currently clear picture of what exactly it does and how one goes about using it and for what.

Perhaps some introductory material to the late model StartupManager after its rebirth would help suggest a name that is informing, short and not in conflict with anything else.

Thoughts?
-=Cliff>


Title: Re: StartupManager - A PureMVC AS3 Utility
Post by: philipSe on July 17, 2009, 03:22:45
I refer to my post above about code in trunk.  It turns out that I was premature in declaring this as a release.  This code is in transition and is not a final version 2.  Use it at your own risk and be aware that the ultimate v2 will probably require you to refactor what you've done.

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