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: Setting texts, labels and styles on view components within a Flash app  (Read 9555 times)
sectore
Courseware Beta
Full Member
***
Posts: 29



View Profile WWW Email
« on: August 21, 2007, 02:36:37 »

Two questions about a "pure" Flash (not Flex) based application:

1) What do you mean is the best practice for setting texts, labels etc. on view components determining by an external XML file?
2) And what is the best place to maintain reusable style definitions such as Fonts, Colors etc.?

Here are my thoughts:

1) Let's assume a multi-lingual Flash based application, which gets its texts, labels etc. from an external XML file. So I have a "ContentProxy", which is acting as a Remote Proxy for loading and parsing the XML file and populating a Value Object called "ContentVO". After that, it dispatches a Notification "XML_LOADED" and its listeners such as a "ApplicationMediator" or a "NavigationMediator" will get the VO for setting texts and labels of its view components.

2) For this issue I defined a "StyleProxy" with static members such as
:
public static const COLOR_BG_SOLID_0: uint = 0x4A9696;
public static const COLOR_BG_BLEND_0: uint = 0x356A6A;
which are connected by the view components without using a "real" instance of the "StyleProxy". Until now I have not created several Mediator for all my view components, but I think that's not the best way... What do you think about this issue? Make it sense to create a Mediator for all view components only for setting "static" styles?




« Last Edit: August 21, 2007, 02:44:25 by sectore » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: August 22, 2007, 08:17:12 »

I think a good way is actually to externalize these color and font constants into an XML file as well. Then use the same approach you're using to set the text labels to set the colors and fonts.

In addition to employing the same pattern, a nice upside is that this would also make these values configurable from the xml without recompiling the swf.

-=Cliff>
Logged
sectore
Courseware Beta
Full Member
***
Posts: 29



View Profile WWW Email
« Reply #2 on: September 09, 2007, 08:45:42 »

Cliff, thanks again for your reply.

2)
You're right, it's a good way to externalize color and font constants into an XML file, too. Another way I've gone is using a simple data object with static members for these properties, similar - but in another context - you're using in your PureMVC Architecture 101 (Unit 3) for enumerations called "RoleEnum". This "data holder" is not a "real part" of PureMVC, which means it's not a Proxy or something else but rather a simple data object using by the views directly without breaking rules.

-sectore
Logged
Pages: [1]
Print