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] 4 5 ... 7
Print
Author Topic: Loadup (formerly StartupManager) - A PureMVC AS3 Utility  (Read 109711 times)
philipSe
Sr. Member
****
Posts: 139


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


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


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

Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



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



View Profile WWW Email
« Reply #34 on: April 06, 2008, 10:03:58 »

Hi Steve,
app = ApplicationFacade.getInstance(Application.NAME)  or am i missing something?

Curtis [Trilec]
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



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


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


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


View Profile Email
« Reply #38 on: April 10, 2008, 04:47:53 »

http://juststeve.com/StartupAssets.zip
Logged
trilec
Sr. Member
****
Posts: 52



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


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


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



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


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


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