6 Replies Latest reply on Nov 13, 2009 11:03 PM by si-robertson

    Conditional ActionScript Compiling

    si-robertson Level 1

      Is it possible to do conditional ActionScript compiling in Flash Builder 4? This is one of Flash CS4's better features.

       

      In Flash Builder 4 it would be cool if we were able to do something like this:

       

       

      CONFIG::IS_AIR_PROJECT {

          // air-specific code here

      }

       

      CONFIG::IS_ACTION_SCRIPT_PROJECT {

          // browser-specific code here

      }

       

      CONFIG::IS_DEBUG_BUILD {

          // debug-pecific code here

      }

       

      COFING::IS_RELEASE_BUILD {

          // release-specific code here

      }

       

       

      ... and so on.

        • 1. Re: Conditional ActionScript Compiling
          CoreyRLucier Adobe Employee

          Works just fine.

           

          Just add -define=CONFIG::XYZ,true


          ..to your additional compiler args for your Flash Builder project.

           

          -C

          • 2. Re: Conditional ActionScript Compiling
            si-robertson Level 1

            Fantastic, thank you.

            • 3. Re: Conditional ActionScript Compiling
              tinylion_uk Level 2

              Would be even better if we could add compiler constants into the actual code of a project rather than having to put them into the compiler args

               

              Is set up all those conditional constants in a top include file into the main project, or even have a compiler arg that loads a file full of condition deffs

               

              I just find it clumsy to have to add them to the compiler arg in prefs.

               

              Its fine when using ant or something as adding to the arguments is simpler just because youre not stuck with that single line text input on the prefs.

               

              At least change the compiler args input to a text area not a text input

              • 4. Re: Conditional ActionScript Compiling
                joan_lafferty Adobe Employee

                Glenn,

                 

                Feel free to log a bug with your requests here.   Its more likely to get considered for the future if its in a bug.

                 

                Thanks!

                Joan

                • 5. Re: Conditional ActionScript Compiling
                  CoreyRLucier Adobe Employee

                  Glenn,

                   

                  This seems to work (possibly undocumented Kung Fu provided by Peter Donovan from the compiler team):

                   

                  package
                  {
                      config namespace FOOBAR;
                      FOOBAR const one = false;
                      FOOBAR const two = true;
                     
                      public dynamic class MyClass
                      {
                          public function MyClass()
                          {
                              super();
                          }
                         
                          FOOBAR::one
                          public function abc():void
                          {
                              trace("one");
                          }
                         
                          FOOBAR::two
                          public function abc():void
                          {
                              trace("two");
                          }
                         
                      }
                  }

                  • 6. Re: Conditional ActionScript Compiling
                    si-robertson Level 1

                    I know this reply is a bit late but I've started to play with conditional compiling again and have one final question to ask.

                     

                    Defining the CONFIG constants within the compiler arguments makes those CONFIG constants global, so you can access them in any class within your project. Defining the CONFIG constants at the top of a class package limits the CONFIG constants to the scope of that class (like private properties).

                     

                    The question is, is it possible to define global CONFIG constants without having to define them within the compiler arguments?