简体   繁体   中英

Flex module to supports 2 clients

Currently I have a task to have to have an flex module to behave differently to 2 clients Some of the difference is text difference and (probably) renderer difference. However the first client will terminated the service soon (within 2-3 months)

So I'm aware that I have this 2 options:

  • Internationalization, but this 2 client are both using English locale (and may force me to create a new locale) for example "en_Client2". After 1st client terminate the service, remove the new locale. ( the second user uses the default locale which is en_US )

  • State, but this will scatter my code with if and else.

Any idea which is the better way? Or there is another option that I missed?

The answer to this question isn't absolute it's an opinion. Here's what I'd do though, setup an xml file with the text that needs to change and the names of the classes to use for renderers for example. Then use a URLLoader or HTTPService to load up the xml file at run-time. Use something like below to resolve the class based on the loaded XML, then assign the class as the itemRenderer dynamically after reading in the data from the XML file. You can store all of it in a model that you can bind to properties in within the view to make it easier.

var classReference:Class = getDefinitionByName(xmlResults.itemRendererNumberOne) as Class;
myList.itemRenderer = classReference;

Then you just make two xml files one for each client and you're good to go.

Note you'll want to include a reference to any classes that will be loaded using getDefinitionByName within the code somewhere, otherwise they won't be included in the swf and it won't be able to resolve them at run-time. Any sort of reference will do though, such as:

MyClass;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM