4 Replies Latest reply on Mar 4, 2009 9:19 AM by Ned Murphy

    Actually doing something with Importing text files

    perro-dave
      Hi all

      I cant believe that Flash will let you load data from a text file then doesn't allow you to do anything with the data other than display it.
      Surely there must be a way you can do something the data imported ie perform some calculations.

      Is this beyond Flash or is this something that has been addressed in AS3?
      All the tutorials I've found all stop at just displaying and 'swonking'.

      Has anyone found a work round for this?

      Dave
      A very disappointed newbie.
        • 1. Re: Actually doing something with Importing text files
          Ned Murphy Adobe Community Professional & MVP
          What makes you think you cannot use data loaded from a text file?
          • 2. Re: Actually doing something with Importing text files
            robdillon Most Valuable Participant
            Place the imported text into a variable and then you can do pretty much as you like with the contents. What do you want to achieve?
            • 3. Re: Actually doing something with Importing text files
              perro-dave Level 1
              Hi

              I'm trying to load some temperature values in from a text file and change the colour of corresponding movie clips depending on the temp value. the basic code I've tried is below, the text from the file loads into labels OK but when i try to put them into variables and get actionscript to do anything with them always returns undefined. I've been told you cant use the values until the form has been reloaded but i dont see why this should be or how to d it without getting the user to press a button every time i want to manipulate the data.
              Any help would be much appreciated.
              Dave

              //Load the file, the labels have var name to match the vars in the file ie temp1 temp2 etc
              loadVariablesNum("temp.txt", 0);

              // The value displays in its label OK.

              // place a value into a as variable and convert to a number and add 2 to it.
              var tempvalue2 = Number(temp2);
              var newtempvalue = tempvalue2 + 2;

              // if value greater than 10 turn mc red else blue

              if (tempsentextTM_txt.text >= "10") {
              sensorColorTM_color.setRGB(0xFF0000); // red
              }
              • 4. Re: Actually doing something with Importing text files
                Ned Murphy Adobe Community Professional & MVP
                I don't think it's a matter of reloading, just a matter of loading. If the code you show is literally as shown, with one line appearing after another, chances are the file hasn't loaded by the time you are trying to use the values that will be read from it.

                I haven't dealt with text files in a wait-for-loading aspect, so I'm not sure what options there are for event listeners. In the help files for this method they show an example that uses setInterval as means of realizing a pseudo-listener.