3 Replies Latest reply on Apr 8, 2007 8:24 PM by kglad

    Whats wrong with my ComboBox???

    Optikalefx Level 1
      numMatch = 5;

      //these are loaded in from a database
      got1a = "Ravens";
      got1b = "Steelers";
      got2a = "Giants";
      got2b = "Raiders";
      got3a = "Patriots";
      got3b = "Cowboys";
      got4a = "Vikings";
      got4b = "Eagles";
      got5a = "49ers";
      got5b = "Seahawks";

      var cbListener:Object = new Object();

      for (i=1;i<=numMatch;i++) {

      this.attachMovie("ComboBox","my_cb" + i,i+1,{_y:40*i,_x:5});

      set("match" + i + "a" , eval("got" + i + "a"));
      set("match" + i + "b" , eval("got" + i + "b"));

      eval("my_cb" + i).addItem({data:1, label:"Pick " + i});
      eval("my_cb" + i).addItem({data:2, label:eval("match" + i + "a")});
      eval("my_cb" + i).addItem({data:3, label:eval("match" + i + "b")});

      cbListener.change = function (evt_obj:Object) {
      set("enter" + i , evt_obj.target.selectedItem.label);
      }//end listener function
      eval("my_cb" + i).addEventListener("change", cbListener);
      }//end for


      check_btn.onRelease = function() {
      //this will trace whatever i have JUST selected trace(eval("enter" + i))
      // I should be able to trace each one based on that enter + i variable like trace(enter1) or trace(enter2) but i cant
      }


      // what im trying to do is be able to send to a database each thing thats selected, but i cant even trace individual boxes. When i use 'i' it works but it shows me what was just selected, why cant i see the enter1 and enter2 variables that are made when you select it?
        • 1. Re: Whats wrong with my ComboBox???
          kglad Adobe Community Professional & MVP
          when your combobox is clicked i has changed. i can't see any reason to do this, but if you want to define variables that are dependent upon the combobox clicked, you need to assign a variable to each combobox so it knows with which i it is associated. like so:

          • 2. Re: Whats wrong with my ComboBox???
            Optikalefx Level 1
            I found a much easier way to do this. just use the cb_number

            for (i=1;i<=numMatch;i++) {

            this.attachMovie("ComboBox","my_cb" + i,i+1,{_y:40*i,_x:5});

            set("match" + i + "a" , eval("got" + i + "a"));
            set("match" + i + "b" , eval("got" + i + "b"));

            eval("my_cb" + i).addItem({data:1, label:"Pick " + i});
            eval("my_cb" + i).addItem({data:2, label:eval("match" + i + "a")});
            eval("my_cb" + i).addItem({data:3, label:eval("match" + i + "b")});

            }//end for


            check_btn.onRelease = function() {
            trace(my_cb2.selectedItem.label);
            }
            • 3. Re: Whats wrong with my ComboBox???
              kglad Adobe Community Professional & MVP
              well, that's what i meant when i said, "...i can't see any reason to do this...".