3 Replies Latest reply on Apr 8, 2007 12:45 PM by Optikalefx

    Dynamic Text Variable Variable

    capulet_x
      Hello,
      I have a movie which loads data from a text file into flash (-no problem there).
      The twist to this is that one of the fields in my movie loads text into fields from a text file which looks similar to the example below:
      myText_district=109
      &myText_Ian=189
      &myText_Dave=8
      &myText_Ray=14

      If I select a specific field in my flash movie and put for example" myText_Ian" as my Var in the properties panel I have no problem getting the "109" to echo at runtime.

      But what I would like to do is specify the Var in the properties panel as something like:

      "myText"+_root.managername

      and still get the same result. You see, I want to define the variable "managername" at runtime in a field so that if I type for example "Dave" in the field the movie will substitute "Dave" in place of the variable "managername" all throughout my actionscript and thus retrieve only info applicable to "Dave".
      The biggest problem for me is that I am stuck with the property panel because I can't apply actionscript directly to a dynamic textfield.

      Is there a syntax that I can use in the Var field of the property panel to get the result I want; to get the variable equivalent to "myText"+_root.managername?

      OR

      Is there an example somone can show me on how to load variables from a text file into a SPECIFIC dynamic text field completely in action script?

      Any help is greatly appreciated.
        • 1. Re: Dynamic Text Variable Variable
          MotionMaker Level 1
          Is there a syntax that I can use in the Var field of the property panel to get the result I want; to get the variable equivalent to "myText"+_root.managername?

          Sorry - no.

          Is there an example somone can show me on how to load variables from a text file into a SPECIFIC dynamic text field completely in action script?
          The Flash help for
          LoadVars.load has the example.
          • 2. Re: Dynamic Text Variable Variable
            Optikalefx
            Dont set the variable in the properties panel. just set an instance name.

            then do your loadVariables("","")
            Then you have to let the variables load in, before using them. Once they are loaded in, then you can assign that text box to whatever variable you loaded in. and because its actionscript you can use an eval(variable + variable)
            so something like this

            your text file:
            &ToF=true&Dave=100

            your flash file:
            var Manager = "whoever";
            this.loadVariables("url","POST");
            if (this.ToF == true) {
            myTextField.text = eval(this.Dave + Manager);
            }

            if you dont have the ToF thing, then your variables will always be undefined. They arent undefined when you have them set right to a property because the flash file waits to load them in. but in actionscritp your using the variables right away, and not waiting to load, thus undefined.
            • 3. Re: Dynamic Text Variable Variable
              Optikalefx Level 1
              Correction, the if statement will only check once, make it a while statement, or put the whole thing inside an interval to keep checking the if statement.