4 Replies Latest reply on Sep 21, 2006 6:44 AM by Newsgroup_User

    Variables problem

    Level 7
      I am asking how can i compare a variable loaded from a txt file with a tex
      in an input text


      For example
      _root.my_btn.onRelease=function{

      if(variable loaded from txt file = = input_txt.text){
      do the following
      }else {
      do the following
      }
      }

      my text file named "ques.txt" at the same folder of my swf
      Please Guys i need this help toooooo muchhh



        • 1. Re: Variables problem
          Nickels55 Level 2
          Looks like you already have the solution, whats the problem?
          Do you not know how to load the .txt variable?
          Are you unsure what the loaded text variable is called?

          The easiest way to figure that out is to test your file and look at the variables, then you can see what they are called. Debug -> List Variables

          PS - it's == not = =
          • 2. Re: Variables problem
            Level 7
            Dear Nickels55

            I know it is == not = = but i wrote it like this son it can be readable

            my problem is i can trace this variable outside the if statements but inside
            it it outputs undefined as if there is now variable from the begining.

            i am loading my variables like this
            _root.loadVariables("ques.txt");

            where ques.txt is the txt file where i store my variables like this:
            &var1 = some txt
            &var2 = some txt 2 and so on

            Please you don't know how much time i spent trying this if you gave me a
            working exemple i will be gratefull :)))

            Thank you for your time
            "Nickels55" <webforumsuser@macromedia.com> wrote in message
            news:ees92n$ool$1@forums.macromedia.com...
            > Looks like you already have the solution, whats the problem?
            > Do you not know how to load the .txt variable?
            > Are you unsure what the loaded text variable is called?
            >
            > The easiest way to figure that out is to test your file and look at the
            > variables, then you can see what they are called. Debug -> List Variables
            >
            > PS - it's == not = =
            >


            • 3. Re: Variables problem
              Rothrock Level 5
              The first thing I notice is that you have

              &var1 = some text
              &var2 = some other text

              This will include the returns at the end of the line. So unless your input_txt.text includes those the two variables will never be equal. So do your text file like this:

              &var1 = some text&
              &var2 = some other text&

              If that isn't it, you should be sure you are waiting for the entire variable file to load before you try and use the variables so if your code (which it would be helpful if you would show the actual bit of code causing problems) looks like this:

              _root.loadVariables("quest.txt");
              if(var1==input_txt.text){
              //code here
              }

              That won't work because there is no time for quest.txt to load before you check for its variables. If you are using a somewhat modern version of Flash I would recommend using LoadVars instead. With that you can define a nice onLoad event to make sure the data is loaded. Check it out in the help files!
              • 4. Re: Variables problem
                Level 7
                I am more than thankfull coz it works only after your help and the funny
                part is that i would never thought of this solution coz i never heard about
                it or read it in a tutorial.

                Good thinking
                Be blessed

                "Rothrock" <webforumsuser@macromedia.com> wrote in message
                news:eeu33u$1fn$1@forums.macromedia.com...
                > The first thing I notice is that you have
                >
                > &var1 = some text
                > &var2 = some other text
                >
                > This will include the returns at the end of the line. So unless your
                > input_txt.text includes those the two variables will never be equal. So do
                > your
                > text file like this:
                >
                > &var1 = some text&
                > &var2 = some other text&
                >
                > If that isn't it, you should be sure you are waiting for the entire
                > variable
                > file to load before you try and use the variables so if your code (which
                > it
                > would be helpful if you would show the actual bit of code causing
                > problems)
                > looks like this:
                >
                > _root.loadVariables("quest.txt");
                > if(var1==input_txt.text){
                > //code here
                > }
                >
                > That won't work because there is no time for quest.txt to load before you
                > check for its variables. If you are using a somewhat modern version of
                > Flash I
                > would recommend using LoadVars instead. With that you can define a nice
                > onLoad
                > event to make sure the data is loaded. Check it out in the help files!
                >
                >