0 Replies Latest reply on Mar 28, 2010 7:10 AM by kubens

    How to deploy on different environments when using DataServices


      I asked this question in the Flash Builder 4 and Flex 4 Labs Archive Forum some weeks ago. But the forum was closed in the meantime so that it is not possible to post further comments there. Therefore I post my solution here, may it is interesting for other people too:


      1. Compiler Argument

      I added a compiler argument for the project: -define+=CONFIG::environment,'dev'


      2. Global Variables

      I defined a global variable in the main application:


           public var BASEURL:String;


      I added in the main application inside the applicationComplete event following logic:


           switch (CONFIG::environment)
           case 'prod':
             BASEURL = 'http://www.woocoom.net/db/';
           case 'dev':
             BASEURL = 'http://www.woocoom.net.localhost:7070/db/';




      3. Generated Sub-Class of Service

      I set the baseURL inside the constructor based on the global variable.


           package net.woocoom.modules.newsstatus.services


             import mx.core.FlexGlobals;


             public class NewsStatusService extends _Super_NewsStatusService


               public function NewsStatusService():void



                 _serviceControl.baseURL = FlexGlobals.topLevelApplication['BASEURL'];




      If I want to switch the environments then I just must change the compiler argument and recompile the project.