What is an alternative to flash config constants?

We have a project that has been built in Flash and as3. It is a video player of sorts that we want to fully customize. We have different images and color schemes that we want to be able to change very quickly. Right now we have config constants that we turn on and off for different schemes. And in the code there is a massive amount of different spots where the images and such are changed.

When we create a new color scheme or whatever, we need to create a new config. Then we have to go through all of the code and put it in correctly.

Basically any suggestions for how we can take the current flash project (maybe flex?) and make it customizable a lot quicker.

Answers


Move all configurable parameters to an XML definition.

Create multiple XML documents for each customization.

In code, establish default values for configurable parameters, then load the XML and reference values of the XML document as overrides to those defaults.

For a production build, XML can be embedded in the assembly if loading an external resource is an issue for deployment.

By loading different configuration XML documents, you could change the definition during runtime, and by using the dynamic configuration model you could draft a theme editor to view changes real time.

ConfigurationModel.as

package
{
    import flash.events.Event;
    import flash.net.URLLoader;
    import flash.net.URLRequest;

    public class ConfigurationModel
    {

        /** ======== configuration ======== */

        public static var color:uint = 0xff00ff;

        public static var fontName:String = "Arial";


        /** ======== serialization ======== */

        public static function loadConfiguration(url:String):void
        {
            var loader:URLLoader = new URLLoader(new URLRequest(url));
            loader.addEventListener(Event.COMPLETE, completeHandler);
        }

        protected static function completeHandler(event:Event):void
        {
            var xml:XML = new XML(event.target.data);

            if (xml.color)
                color = xml.color;

            if (xml.fontName)
                fontName = xml.fontName;
        }

    }
}

Example configuration: AcmeClientConfiguration.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <color>0xff0000</color>
    <fontName>Calibri</fontName>
</configuration>

Need Your Help

struts2 convention plugin doesn't work in an EAR but works fine in WAR

java struts2 struts2-convention-plugin

When I deployed the WAR file the convention plugin was able to find the action class using annotations, but it fails to find the action with in an EAR.