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 31942 times)
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« on: September 29, 2008, 06:50:29 »

This demo illustrates the use of the PureMVC framework, the Startup Manager Utility, and its new Asset management classes to load display assets at startup.

The demo is located at http://trac.puremvc.org/Demo_AS3_Flex_StartupForAssets

The author is Philip Sexton.

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

The new thread is here: http://forums.puremvc.org/index.php?topic=1395.0
« Last Edit: August 16, 2009, 07:17:33 by puremvc » Logged
philipSe
Sr. Member
****
Posts: 139


View Profile Email
« Reply #1 on: September 30, 2008, 05:17:54 »

Note that this demo requires the latest version of the StartupManager utility, that is, version 1.5, which has just been tagged as the current version.
----Philip
Logged
lulumOriss
Jr. Member
**
Posts: 14


View Profile Email
« Reply #2 on: October 18, 2008, 02:40:47 »

Hi,

I try to set up this demo for my development.
My files are well loaded but I can't understand how I have to store assets data in an appropriate proxy.
I think I have to register a proxy for each assets url but...

Here's my StartupCommand :

:
public class StartupCommand extends SimpleCommand implements ICommand
{
override public function execute( note:INotification ) : void
{
this.facade.registerProxy( new SettingsProxy( ) ); // this is the proxy where I want to store data from "assets/settings.xml"

var l_fileList:Array = [
"assets/settings.xml"
];
this.facade.registerProxy( new Proxy( ApplicationFacade.URL_GROUP_PROXY, l_fileList ) );
this.facade.registerMediator( new ApplicationMediator( note.getBody( ) ) );
}
}

Can anyone help ? lulu.

Subsidiary question : when I try to load a .css file, my application crashes (in a previous demo, it worked). Do you know why ?
Logged
philipSe
Sr. Member
****
Posts: 139


View Profile Email
« Reply #3 on: October 20, 2008, 04:57:04 »

Is your ApplicationMediator the same as the one in the demo?

The ApplicationMediator has a var 'groupOfUrls'; it expects to be assigned an array of urls.  Your code indicates that you provide an array containing the single url, that for the xml file.  And I think you say that it loads.

If I understand you correctly, your settings proxy has to process the xml file content and get from it the set of urls for the assets that you wish to load.  And you then have to process this set as another group of urls to be loaded.  So it's a two-step process.  Is this the requirement?

Also, the StartupManager Utility asset Loader feature does not currently recognise files of type .css.  I should add this as a text asset type, presumably.  In the meantime, one workaround is for you to extend the AssetFactory class and override the urlToType function.

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

Apart from .css, what other types should I include?
----Philip
Logged
lulumOriss
Jr. Member
**
Posts: 14


View Profile Email
« Reply #4 on: October 20, 2008, 08:04:08 »

Hi,

thank you for your reply.

Actually, I just want to set my data from each url (just one in my sample code but the same for more) in a specific proxy.
I use the same ApplicationMediator as the one on the demo and in the NEW_ASSET_AVAILABLE handler, I compare the url to set the appropriate proxy (see below).

I guess there's an automatic process to do this. Isn't it ?

:
private function setProxyData( p_asset:IAsset ):void
{
var l_proxyName:String;
var l_data:*;
switch( p_asset.url )
{
case DefaultAssetsURL.SETTINGS_URL:
l_proxyName = SettingsProxy.NAME;
l_data = new XML( p_asset.data );
break;
}
var l_proxy:IProxy = this.facade.retrieveProxy( l_proxyName );
l_proxy.setData( l_data );
}

//[...]
case StartupManager.NEW_ASSET_AVAILABLE:
this.setProxyData( note.getBody( ) as IAsset );
break;
//[...]

Thanks for the .css.
No other type wish for the moment.

lulu.
Logged
philipSe
Sr. Member
****
Posts: 139


View Profile Email
« Reply #5 on: October 20, 2008, 08:47:24 »

Still not sure what your question is...

By using the StartupManager assetLoader, there is an AssetProxy created for each url.  Each asset proxy has the url string as its name and has the IAsset object as its data.  Hence, facade.retrieveProxy(url) can be used to get a reference to the asset proxy.

Does this help?

Also, let me just repeat the following question, to make sure it is addressed to all interested developers.
The currently supported set of types in the AssetFactory urlToType method are
- image type: .jpg, .gif, .png
- text type: .txt, .xml
- swf type: .swf

Apart from .css, what other types should I include?
----Philip
Logged
lulumOriss
Jr. Member
**
Posts: 14


View Profile Email
« Reply #6 on: October 20, 2008, 08:58:59 »

ok.
You solve my problem.

Thanks.
Logged
lulumOriss
Jr. Member
**
Posts: 14


View Profile Email
« Reply #7 on: October 21, 2008, 08:04:17 »

I'm back javascript:void(0);

I have understood where the data are stored after loading but, actually, I want to use a personal proxy with specific methods.
What is the best way to do this ?

Thanks. lulu.

(I try to be clear but...)
Logged
philipSe
Sr. Member
****
Posts: 139


View Profile Email
« Reply #8 on: October 21, 2008, 09:07:18 »

First, note that after the load, in addition to the AssetProxy objects, there is an AssetGroupProxy object that is a single proxy for the group of assets.

As regards the personal proxy, I suppose you design it to have the behaviour you require and you populate it from the data that has been stored in the AssetProxy objects.

----Philip
Logged
lulumOriss
Jr. Member
**
Posts: 14


View Profile Email
« Reply #9 on: October 21, 2008, 10:19:37 »

Yes, that's the idea.
Should I transfer data from the default proxy to my personal one in the NEW_ASSET_AVAILABLE handler (like I did in my sample code above) ?
Logged
philipSe
Sr. Member
****
Posts: 139


View Profile Email
« Reply #10 on: October 22, 2008, 08:23:22 »

Yes, that's ok.
----Philip
Logged
crypt
Jr. Member
**
Posts: 16


View Profile Email
« Reply #11 on: May 18, 2009, 08:18:54 »

Hi Folks!
I am making a photo viewer app in pure flash environment with puremvc,
I have a problem loading multiple thumbnail jpegs using assetloader: Type was not found or was not a compile-time constant: UIComponent... this utility in only for flex?

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


View Profile Email
« Reply #12 on: May 19, 2009, 03:03:32 »

@crypt
The assetloader feature is part of the StartupManager utility (SM). 

In that utility, there are 2 interfaces available for assets: IAsset and IAssetForFlex.  The 3 supplied asset classes implement IAssetForFlex - the 3 classes are AssetOfTypeImage, AssetOfTypeSwf and AssetOfTypeText - the code content is extremely small.  If you want to avoid IAssetForFlex, and thus avoid UIComponent, you could create your own versions of these asset classes to extend AssetBase and implement just IAsset.

Let me try to be more comprehensive in my reply.  Say you want to continue to just include the SM utility as a lib component - the .swc file.  In that case. it seems to me, you could do the following
- create your own 3 classes as described above, but with different  names
- create your own AssetTypeMap class, different name, implementing IAssetTypeMap; the only change from the utility version is to substitute your own names for the 3 asset classes
- create your own LoadAssetGroupCommand class, different name; the only change from the utility version is to substitute your own name for the AssetTypeMap class.

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


View Profile Email
« Reply #13 on: May 19, 2009, 03:16:38 »

Thanks! It's help a lot! Meanwhile i hacked the files you mentioned, but the sollution you prefer is much more elegant! I would go that way. Thanks for fast reply!
Logged
crypt
Jr. Member
**
Posts: 16


View Profile Email
« Reply #14 on: May 20, 2009, 07:30:23 »

just one more question :-)

i am loading small thumbnails LoadAssetGroupInstructions, In groupOfUrls:Array i defined thumnails url's,   but the loading sequence is different from groupOfUrls. Is there any sollution for this? To sequence the loading?

I use this command when new asset is available:
case StartupManager.NEW_ASSET_AVAILABLE:
                   popupThumbnails.addItem( ((note.getBody() as IAsset).data) as DisplayObject );

That's ok, but I need more information about thumbnails not just pure bitmap data. How can i send and receive other paramaters about assets? Like id, name, url, comment... ?

thanks!!
crypt
Logged
Pages: [1] 2
Print