Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1] 2 3 ... 7
Print
Author Topic: Loadup (formerly StartupManager) - A PureMVC AS3 Utility  (Read 109714 times)
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« 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
« Last Edit: January 20, 2011, 09:16:53 by puremvc » Logged
justSteve
Courseware Beta
Sr. Member
***
Posts: 55


View Profile Email
« Reply #1 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...
Logged
james.douma
Newbie
*
Posts: 1


View Profile Email
« Reply #2 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. 
Logged
philipSe
Sr. Member
****
Posts: 139


View Profile Email
« Reply #3 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
Logged
jowie
Jr. Member
**
Posts: 19


View Profile Email
« Reply #4 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 ;)
Logged
philipSe
Sr. Member
****
Posts: 139


View Profile Email
« Reply #5 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
Logged
trilec
Sr. Member
****
Posts: 52



View Profile WWW Email
« Reply #6 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
 
« Last Edit: March 28, 2008, 04:02:13 by trilec » Logged
dbasch
Jr. Member
**
Posts: 17


View Profile Email
« Reply #7 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
Logged
philipSe
Sr. Member
****
Posts: 139


View Profile Email
« Reply #8 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
Logged
philipSe
Sr. Member
****
Posts: 139


View Profile Email
« Reply #9 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

Logged
trilec
Sr. Member
****
Posts: 52



View Profile WWW Email
« Reply #10 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

« Last Edit: March 31, 2008, 12:19:46 by trilec » Logged
kouri
Courseware Beta
Full Member
***
Posts: 28


View Profile Email
« Reply #11 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... ;)





« Last Edit: April 01, 2008, 09:22:54 by kouri » Logged
philipSe
Sr. Member
****
Posts: 139


View Profile Email
« Reply #12 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
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #13 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>
Logged
justSteve
Courseware Beta
Sr. Member
***
Posts: 55


View Profile Email
« Reply #14 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...
Logged
Pages: [1] 2 3 ... 7
Print