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]
Print
Author Topic: How to treat Flex StyleManager  (Read 8321 times)
pwhitfie
Courseware Beta
Newbie
***
Posts: 3


View Profile Email
« on: March 02, 2008, 03:53:28 »

Hi all,

I've been working on porting the Adobe AIR employee directory sample app to PureMVC as a learning exercise and I've come across a question that I'd like some input on.

The existing app has the following code in a LoadStyleSheetCommand:

:
var declEvent:IEventDispatcher = StyleManager.loadStyleDeclarations( fileName );
declEvent.addEventListener( StyleEvent.COMPLETE, onStyleLoad );
declEvent.addEventListener( StyleEvent.ERROR, onStyleLoadError );

If my understanding is correct, we shouldn't be using Flex events in a Command so here is my question:

do I treat the Flex StyleManager as a UI component and therefore create a StyleManagerMediator?

or is there a better way to handle this?

I'm inclined to come down on the side of the Mediator approach as this keeps all Flex event handling in the view.

Any suggestions?

Thanks,

Pete

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



View Profile WWW Email
« Reply #1 on: March 02, 2008, 06:09:33 »

Since it communicates with the outside world, we would consider the StyleManager a Boundary object.

But it comminicates with the server to fetch the file.

It could be seen as communicating with the user, but really it just informs the view about how to look in the same way that data fron a remote database, once fetched, informs the view about what to display.

So from that perspective, the natural place for this code would be in a Proxy.

It is common to create a service in a Proxy and set listeners on it for its result and fault events in the same way you described in your code.

Event handling happens at both boundries of the app, not just in the View.

-=Cliff>   
Logged
pwhitfie
Courseware Beta
Newbie
***
Posts: 3


View Profile Email
« Reply #2 on: March 02, 2008, 03:14:34 »

Thanks Cliff!

I had thought about this as well but confused myself by thinking that Proxies were specifically for managing data. Having gone back to look at the IProxy interface I now realise that the interface does not impose any limits.

Thanks for your help.

Cheers,

Pete
Logged
Pages: [1]
Print