• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Best practices for setting environment based static variables?

Explorer ,
Mar 06, 2012 Mar 06, 2012

Copy link to clipboard

Copied

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?

Views

966

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 06, 2012 Mar 06, 2012

Copy link to clipboard

Copied

LATEST

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;

     }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines