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]
Print
Author Topic: Startup for Assets - A PureMVC AS3 / Flex / StartupManager Demo  (Read 19490 times)
philipSe
Sr. Member
****
Posts: 139


View Profile Email
« Reply #15 on: May 22, 2009, 03:09:12 »

@crypt
Is there any sollution for this? To sequence the loading?
As you may know, the StartupManager utility (SM) has a sequencing feature - see StartupAsOrdered demo. So, you could do the following, in your load assets command
- make and register a StartupResourceProxy object for each asset; say ar1, ar2, etc
- express the sequencing by using the appropriate requires statements, for example: ar2.requires = [ar1];
- use addResource() instead of addResourceViaStartupProxy().

other parameters about assets? Like id, name, url, comment... ?
Maybe the following
- extend IAsset to include the additional attributes
- in your load assets command, when each asset is instantiated using the AssetFactory, set the additional attributes on the asset; this assumes that the additional attributes are available from the same source as the url string, so maybe groupOfUrls is not just an array of urls, maybe each array element contains the url plus the additional attributes.

Hope this helps.
----Philip
Logged
crypt
Jr. Member
**
Posts: 16


View Profile Email
« Reply #16 on: May 22, 2009, 09:55:19 »

THANKS! I make a copy of the original LoadAssetGroupCommand, now I called it LoadAssetGroupAsyncCommand

and looks like:
            var prevProxy:StartupResourceProxy;
            for ( var i:int=0; i < groupOfUrls.length; i++ ) {
                var url :String = groupOfUrls;
                if ( facade.hasProxy( url )) {
                    sendNotification( StartupManager.URL_REFUSED_PROXY_NAME_ALREADY_EXISTS, url, groupId );
                }
                else {
                   
                    var asset :IAsset = assetFactory.getAsset( url );
                    var px :IStartupProxy = new AssetProxy( groupPx, url, asset );
                    facade.registerProxy( px );
                   
               var rAssetProxy:StartupResourceProxy = makeAndRegisterStartupResource( url , px );
               if(prevProxy!=null)rAssetProxy.requires = [ prevProxy ];
               prevProxy = rAssetProxy;
                   
                }
            }
Logged
crypt
Jr. Member
**
Posts: 16


View Profile Email
« Reply #17 on: June 01, 2009, 04:14:11 »

Just one more.. ;-)

I have a mediator (ThumbnailsMediator.as) that is for viewing small thumbnails of photos from the current category. So if you change category, there will be showed another thumbnails.
In this mediator I use StartupManager.NEW_ASSET_AVAILABLE - notification and a command
popupThumbnails.addItem( ((note.getBody() as IAsset).data) as DisplayObject );
to add new items to the view. It's okey..

if i change category new thumbnails will be loaded and new_asset_available notification willl fire.. but if I change back to the previous category, i can't use this notification because they are already loaded.
what do you think? what can I do in this situation?


thanks!
Logged
philipSe
Sr. Member
****
Posts: 139


View Profile Email
« Reply #18 on: June 02, 2009, 02:46:24 »

I'm sorry. I don't understand the question.

Is there a separate ThumbnailsMediator instance for each category?  When you change back to the previous category, are the thumbnails displayed?  Is each category treated as a separate asset group with it's own AssetGroupProxy instance?

The NEW_ASSET_AVAILABLE notification has the the asset group proxy name as notification type.  This can be used in the mediators to determine whether a notification is relevant.

Hope this helps.
----Philip
Logged
crypt
Jr. Member
**
Posts: 16


View Profile Email
« Reply #19 on: June 02, 2009, 03:31:26 »

Thanks for your fast reply, my english is bad.. ;-)

No I have only one ThumbnailsMediator, I want to use this to display all of the categorys, (maybe this is the problem..). It has a viewComponent: popupThumbnails.

If I change category first I use my method to remove all thumbnails >  popupThumbnails.removeAll();

After it I am listening to NEW_ASSET_AVAILABLE notification, and if a new asset is available > popupThumbnails.addItem(..

but if I change back to the previous category, i can't use this notification because this notification will not fire again, because this assets are already loaded somewhere
Logged
philipSe
Sr. Member
****
Posts: 139


View Profile Email
« Reply #20 on: June 02, 2009, 06:29:44 »

ok, so one possibility is...
- a mediator instance per category, with a mediator name that is same as asset group proxy name
- a popup thumbnails component instance per category; maybe it doesn't have to be a popup, but maybe you want it to be, so whatever you choose.

another possibility, closer to your existing approach, is...
- when you change back to a previous category, the mediator needs to know this; via a notification if needs be, say we call this 'redisplay'
- in mediator, on redisplay, get all the loaded assets from the relevant asset group proxy (via getData() say) and add them to the mediator's view component.

Or maybe you can see other better approaches now.
----Philip

maybe you
Logged
crypt
Jr. Member
**
Posts: 16


View Profile Email
« Reply #21 on: June 02, 2009, 06:50:57 »

okey! fine! thanks!
now I can go on! :-)
Logged
philipSe
Sr. Member
****
Posts: 139


View Profile Email
« Reply #22 on: July 12, 2009, 04:52:30 »

There is a new version of the StartupForAssets demo in the code repository; in trunk, not tagged.

Here is the relevant extract from version.txt.

2.0 - Requires StartupManager Utility version 2.0.  Now demonstrates
    loading of single assets as well as a group of assets, concurrently
    if desired.
Logged
philipSe
Sr. Member
****
Posts: 139


View Profile Email
« Reply #23 on: July 17, 2009, 03:36:28 »


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

Arising from that, my post above about this demo code in the repository trunk is premature, since there is not yet a StartupManager Utility version 2.0.  Hence, this demo code is in transition and is not a final version.  Use it at your own risk and be aware that the ultimate version will probably require you to refactor what you've done.

My apologies for any inconvenience caused.
----Philip
Logged
Pages: 1 [2]
Print