6 Replies Latest reply on Apr 5, 2007 9:46 PM by kglad

    Control Text Field

    pcst88
      I have a ComboBox instance named: imageCb and a Dynamic Text Field named: matric_txt.

      I want the matric_txt text to be read from a an external file (that is on the same location). But that file is different for every value of the combo box, the names of the files are the same as the cmoboBox labels (Foto 1, Foto 2...). I tried using Listeners, but I couldn't get it done.

      How can I load different text files into the same Dynamic text Field on a comboBox value change using AS?
        • 1. Re: Control Text Field
          kglad Adobe Community Professional & MVP
          use a combobox change listener that loads the appropriate text file using the LoadVars() class. use the onLoad() method of the LoadVars() class to assign text to your textfield.
          • 2. Re: Control Text Field
            pcst88 Level 1
            that's where I get lost, I don't know how to past the name of the file to the Text Field when I chose a value on the comboBox
            • 3. Re: Control Text Field
              kglad Adobe Community Professional & MVP
              try:

              • 4. Re: Control Text Field
                pcst88 Level 1
                thanks that's a useful code, I'm trying to use XML now though and I'm trying to get the index out of the comboBox, this is my code, and it's wrong, I dunno if I'm passing the index wrong or the listener is not good :S var cont_var:Number;

                quote:


                var listenr_var:LoadVars = new LoadVars ();
                listenr_var.addListener(numberListener);

                listenr_var.LoadVars(imageCb.selectedIndex, cont_var);

                function toggleNumber (event:Object):Void {
                listenr_var.LoadVars(imageCb.selectedIndex, cont_var);
                }

                var matric_xml = new XML ();
                matric_xml.ignoreWhite = true;
                matric_xml.load ("matriculas.xml");

                matric_xml.onLoad = function () {
                matric_txt.text = cont_var;
                }

                • 5. Control Text Field
                  pcst88 Level 1
                  I was checking my code, and the problem is at listener part.

                  quote:

                  var listenr_var:LoadVars = new LoadVars ();
                  listenr_var.addListener(numberListener);

                  listenr_var.LoadVars(imageCb.selectedIndex, cont_var);

                  function toggleNumber (event:Object):Void {
                  listenr_var.LoadVars(imageCb.selectedIndex, cont_var);


                  may someone help me?
                  • 6. Re: Control Text Field
                    kglad Adobe Community Professional & MVP
                    what's the relationship between your xml file and your combobox?

                    and you'll need to parse your xml file (after it loads) to use the data it contains. for more specific help on parsing your xml file you'll need to paste its contents here.