1 Reply Latest reply on Oct 5, 2010 10:03 AM by kglad

    Reading external .txt as code

    scalhoun11 Level 1

      I'm trying to pass a variable into my program through an external .txt file. Here's the basic code:

       

      numberOfColors = new LoadVars();
      numberOfColors.onLoad = function()
      {
          numberOfColors_text.text = this.myNumberOfColors;
      };
      numberOfColors.load("Text/NumberOfColors.txt");

       

      Then within the NumberOfColors.txt it reads:

       

      myNumberOfColors=3

       

      Everything loads just fine into my numberOfColors_text text field.

       

      My question is is there any way for Flash to read that number 3 as a variable so I could set up an if/then statement where I could say if (myNumberOfColors == 3) or if (myNumberOfColors == 4), etc? Can Flash convert external into code?