2 Replies Latest reply on May 14, 2010 12:36 AM by iamelleL

    urgent help: access external .txt file that I can edit anytime

    iamelleL

      hi! please help me in my problem. I'm creating an AIR application that connects to a sever. This application should be installed in multiple computers and connect to a single sever. My problem is how I can specify the server's domain name or IP because I used HTTPService in getting data from the database. My idea was to get the server's Domain name or IP from an external text file. I used the

                               [Embed(source="serverIP.txt", mimeType="application/octet-stream")]

                   private static const serverAdd:Class;

       

      but then I realized I can't edit the serverIP.txt anymore it will be converted or something. =(( please help I need another method.

       

      here's my code

       

      package Constant

      {

       

      public class ConstantVariables {       

       

              [Embed(source="serverIP.zion", mimeType="application/octet-stream")]

              private static const serverAdd:Class;

       

              public static function get vrieniHttpURL():String

              {

              var svrAdd:Object = new serverAdd();

              var v:String = 'http://'+ svrAdd.toString() +'/zion/php/';

              return v;

              }

      }

       

      }

       

       

      the serverIP.txt contains the domain name.

        • 1. Re: urgent help: access external .txt file that I can edit anytime
          BhaskerChari Level 4

          Hi,

           

          You can use two approaches :

           

          1) Simply save the domain name in a variable within your AIR application and then access that variable.

           

          2) Place the serverIP.txt file in your domain server and your AIR application should download that txt file using the UrlLoader class and read the domain name from that file. This way it will be very helpful as you can chnage the domain name any time in your server and it will automatically be reflected in your AIR app.

           

          Instead of txt file you can use xml file which can have any other data you require so that you can easily load and use the xml file in your AIR app.

           

          Please mark it as answered if it helped you.

           

          Thanks,

          Bhasker Chari.S

          • 2. Re: urgent help: access external .txt file that I can edit anytime
            iamelleL Level 1

            how will I use the URLLoader? wouldn't I need the domain name for that? I'm so sorry im not familiar with it.

            but would it be possible to access my external file from the programs file folder or the directory where I installed the air application?