5 Replies Latest reply on Jul 15, 2009 8:29 AM by Drew_CA

    Configuration File - Where are you?

    Drew_CA Level 1

      Does Flex not have any default configuration file like .NET does (App.Config or Web.Config)?

       

      What are my best options to achive this?  I was thinking custom XML but wanted to see other opinions.

       

      Thanks.

       

      Drew

        • 1. Re: Configuration File - Where are you?
          msakrejda Level 4

          There are a number of config files. In the mxmlc, you specify the services file (to define AMF endpoints) using the argumet

           

          -services /path/to/services-config.xml

           

          and the general config in

           

          -load-config /path/to/config/flex-config.xml

           

          You can use += (instead of -) on both of these to add options (i.e., override defaults rather than replace them all with the files specified). The default config file is in $FLEX_HOME/frameworks/flex-config.xml. For all the options, check the reference here: http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_13.html

          • 2. Re: Configuration File - Where are you?
            *Prashant Shelke* Level 4

            For installed Flex plugin 3.0 I used to go for


            C:\Program Files\Adobe\Flex Builder 3 Plug-in\sdks\3.0.0\frameworks\flex-config.xml


            & for web project

            project\WEB-INF\flex\flex-config.xml

            • 3. Re: Configuration File - Where are you?
              Drew_CA Level 1

              Can these files be used for my own custom config on an application level.

              I have 1 web app that needs to be delivered on many sites but each app needs different settings..

              For example: I need global variables for things such as.

               

              var siteTitle = "ABC";

              var webServiceUrl = "http://..................";

              var homepageUrl = "http://...................";

               

              Drew

              • 4. Re: Configuration File - Where are you?
                msakrejda Level 4

                I don't believe so. With a build tool like ant, you could write a

                build script that could pre-process a plain .as file to fill this in.

                 

                E.g., you can have a class template like

                 

                public class SiteInfo {

                    public var siteTitle:String = "@site.title@";

                    public var webServiceUrl:String = "@site.webservice.url@";

                    public var homepageUrl:String = "@site.homepage.url";

                }

                 

                and various properties files like

                 

                mysite.properties:

                 

                @site.title@=My Site

                @site.webservice.url@=http://mysite.com/...

                @site.homepage.url@=http://mysite.com/...

                 

                and

                 

                myothersite.properties:

                 

                @site.title@=My Other Site

                @site.webservice.url@=http://myothersite.com/...

                @site.homepage.url@=http://myothersite.com/...

                 

                and use ant to do token replacement for each different target.

                 

                E.g.,

                 

                ant build -Dsite=mysite

                 

                It's possible that there's a way to do this more cleanly using Flex's

                build system, but the ant-based approach will certainly work.

                 

                Also, consider that you may have access to some of this info already

                in the running swf (e.g., Application.application.url) and for things

                like web services, you may be able to use a relative url. Site title

                is a little more complicated.

                 

                Another thing you could do is store these settings in an external XML

                file and load them at startup. That's probably the cleanest solution.

                • 5. Re: Configuration File - Where are you?
                  Drew_CA Level 1

                  Thanks for your reply msakrejda.

                  I was thinking the custom XML way and that may be how I do it.

                  I will look into all your suggestions.

                   

                  I also found this: http://www.herrodius.com/blog/63

                   

                  Thanks again!

                   

                  Drew