1 Reply Latest reply on Mar 6, 2012 2:44 PM by a-fro

    Best practices for setting environment based static variables?

    a-fro

      I have a set of static string variables that hold the url location of modules in a project. These locations change depending on whether I'm building for development, staging or production.

       

      What's the best way to set static variables in this way?

        • 1. Re: Best practices for setting environment based static variables?
          a-fro Level 1

          I don't know if this is best practice, but here's the solution I've come up with.

           

          The root domain is accessible within the swf via a node on a loaded xml file. So I created a simple method that sets a url variable based on that domain node.

           

          The domain-based url variable is then used within the static string variables that define the location of the modules.

           

          Simplified like so:

           

          var domain:String = xml.node.value;

           

          static var bucketLocation:String = getLocation()

           

          static var moduleLocation:String = bucketLocation + "modulename.swf";

           

          function getLocation():String

          {

               var loc:String

               switch (domain) {

                    case stagingUrl:

                        loc = "pathToAmazonStagingBucket";

                         break;

                    case productionUrl:

                         loc = "pathToAmazonProductionBucket";

                         break;

               }

          }