Search code examples
testingflex4httpservice

Flex 4 - Technique to allow HTTPService testing locally and on development server


Right now I have my URLs hard-coded for HTTPService to work with my local machine's web server so that I don't need to copy files to htdocs after compiling. What's a good technique to easily transition HTTPService URLs from working on my testing setup to working with a normal web server setup?


Solution

  • Write a service to get the current environment your application is in, similar to how one tests if you're running in AIR or Flex.

    In your HTTPService:

    url="EnvironmentService.getURL1();"
    

    In EnvironmentService:

    public static function getUrl1():URL
    {   
         return (LOCAL_ENVIRONMENT)? LOCAL_URL1 : LIVE_URL1;
    }
    

    If this doesn't work for you, post some more code and we'll work on a solution