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

android: Set clicked color of Tab to background color of a TableRow

android tabs

I have a TabLayout. In that I have a tablelayout with dynamically added rows.

Perform Segue from Root View Controller of a UIPageViewController

ios objective-c

I have a UIPageViewController and have a button in it. Whenever the button is pressed I want to perform a Segue from the parent view controller (which has a navigation controller embedded) to the n...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.