PureMVC Architects Lounge

Announcements and General Discussion => Getting Started => Topic started by: mathias on December 23, 2007, 12:50:29



Title: Where should visual theme assets go?
Post by: mathias on December 23, 2007, 12:50:29
Hi everyone,

first of all - thank you for this great framework, and the lively discussion.

I'm new to PureMVC and currently reworking a flash app to benefit from it. My app uses different visual themes that can be swapped at runtime. Theme assets include CSS files, fonts and images which are also loaded at runtime when needed. Any number of view components might use (share) them... I feel the best way to handle these assets would be by loading and caching them with remote proxies.
Now, although this sounds clearly view related, i'm wondering wether my view mediators should take care of it -- or if the model would be a better place. After all, these theme assets are persistent data and not coupled to any particular view components.

...

One other thing regarding these remote proxies: is it ok (or perhaps common) to mix Proxy with Facade? I'd want to do something like this:
1. proxy is asked to load all assets for a specific theme
2. proxy delegates to 3 subproxies, each responsible for loading and caching different asset types (css, font, img)
3. subproxies send onLoadComplete events to proxy
4. proxy notifies the app about the theme being ready to use
5. views can now retrieve assets through the proxy

Well, maybe this isn't a proxy after all, but rather a facade in front of 3 proxies? Would it still be registered with the model?


Thanks a lot for any thoughts on this.


Title: Re: Where should visual theme assets go?
Post by: Joel Hooks on December 25, 2007, 01:20:59
There is a really tight asset loading example in the ApplicationSkeleton example posted here (http://forums.puremvc.org/index.php?topic=21.15). The example is Flex, but I believe the proxy setup would carry over directly to Flash.


Title: Re: Where should visual theme assets go?
Post by: Peter on December 27, 2007, 02:57:08
I'm using a Command to govern the loading process of assets.

1. I've registered several Commands to load assets with the ApplicationFacade, like LoadMovieCommand.
2. The viewcomponent broadcasts an event to its Mediator, like onChange.
3. The Mediator sends a Notification which invokes LoadMovieCommand
4. LoadMovieCommand retrieves a remote Proxy to load a swf
5. When loaded, the remote Proxy sends a Notification which invokes a Command - like AddViewsCommand.
6. AddViewsCommand evaluates what has been loaded (for instance by looking at the type of the Notification) and based on the result, sends a Notification to invoke another Command like LoadCSSCommand -> step 5 (you can also sequence the loading of several swf's this way).
7. AddViewsCommand decides if all assets are loaded and sends a Notification using the body and optionally the type of the Notification to pass any data to the Mediator.