16 Replies Latest reply on Dec 9, 2009 2:25 AM by OblivionKnight

    Newbie - dependable comboBox Flash 8

    NcCMbC
      Hi everyone, I've never used this before, so go easy on me. I'm having trouble with getting a dependable combobox functioning. Actually, I don't have a clue. So could someone point me in the direction of a tutorial or functioning example I could download as a guide. I have one for MX, but it has a variable not present in Flash 8 and I have no idea what to do with it or how to recreate it.

      Cheers,
        • 1. Re: Newbie - dependable comboBox Flash 8
          kglad Adobe Community Professional & MVP
          here are the essentials:

          • 2. Newbie - dependable comboBox Flash 8
            NcCMbC Level 1
            Thanks, but oh wow, totally over my head. lo and eo are the instance names? It took me hours just to get a combo box that would actually do something when a selection was chosen. Now I'm completely baffled as to how to put two comboboxes on the stage and have the first one provide the list for the second and then for the timeline to jump to a frame when the selection is clicked...
            • 3. Re: Newbie - dependable comboBox Flash 8
              kglad Adobe Community Professional & MVP
              no, lo is the name of a listener object that's created on line 1. you need change nothing for your application.

              eo is an event object that's passed by the object that calls the change method. you need change nothing for your application.

              cb is the only thing you need to change to match the instance names of one of your comboboxes.

              if you use your first combobox, you'll used the selectedItem's data (probably) to populate your 2nd combobox using the 2nd comboboxes dataProvider property.
              • 4. Re: Newbie - dependable comboBox Flash 8
                NcCMbC Level 1
                I understand now, mostly. Thank you for taking the time to answer my question, I just have one final part that I'm not sure about:

                "if you use your first combobox, you'll used the selectedItem's data (probably) to populate your 2nd combobox using the 2nd comboboxes dataProvider property."

                I think I understand, but really I would be just guessing. I'm not sure how to populate the data into the second combobox and get it to jump to a frame when selected. gotoandstop command?

                Do you have a suggestion for a good tutorial book to learn these basics? I'm a graphic designer, so I learn by example, not by learning rules then applying them in different situations - math, lol

                Cheers,
                • 5. Re: Newbie - dependable comboBox Flash 8
                  NcCMbC Level 1
                  Did I mention it has to be compatible with version 6 and up?
                  • 6. Re: Newbie - dependable comboBox Flash 8
                    Optikalefx Level 1
                    this might be confusing, but i tried to explain each part bit by bit
                    • 7. Re: Newbie - dependable comboBox Flash 8
                      Optikalefx Level 1
                      // "label:"Game"" the second thing a combo box needs, is w

                      i meant label1 not Game (sorry used from my own code)
                      • 8. Re: Newbie - dependable comboBox Flash 8
                        NcCMbC Level 1
                        Thank you Optikalefx!!!! You are a life saver!! I want to learn more about Flash and ActionScript so that I won't have to restrict my creativity because I don't know how to implement a function - Cheers!!
                        • 9. Re: Newbie - dependable comboBox Flash 8
                          NcCMbC Level 1
                          Oops, I get a bunch of errors... I fixed most of them, at least I think I did, but these remain...

                          **Error** Scene=Scene 1, layer=action, frame=1:Line 21: Statement block must be terminated by '}'
                          myListener.change = function(event:Object) {

                          **Error** Scene=Scene 1, layer=action, frame=1:Line 62: Syntax error.
                          }

                          Total ActionScript Errors: 2 Reported Errors: 2
                          • 10. Re: Newbie - dependable comboBox Flash 8
                            Optikalefx Level 1
                            ha, i guess i should have tested my code, i just typed it up here. i made some minor changes, names and such, and cleaned it up, with no comments, the same basic idea, except one thing. I had to create all the combo boxes in the start, make them invisible, and them when called, make them visible, it works fine, as u can see heres the code, straight copy and paste it and test it.
                            • 11. Re: Newbie - dependable comboBox Flash 8
                              Optikalefx Level 1
                              if you want to get "codie" at the top instead of doing attach movie a million times
                              just use a for statement

                              for (i=1;i<=4;i++) {
                              this.attachMovie("ComboBox","my_cb" + i,_root.getNextHighestDepth(),{_y:0,_x:150*i});
                              set("my_cb" + i + ".visible" , false);}
                              this.attachMovie("ComboBox","my_cb",_root.getNextHighestDepth(),{_y:0,_x:0});
                              • 12. Re: Newbie - dependable comboBox Flash 8
                                NcCMbC Level 1
                                Thank you again, that is great. I appreciate you taking the time on this. Is there a way to have only two comboboxes or to have the first box change the contents of a list?
                                • 13. Re: Newbie - dependable comboBox Flash 8
                                  Optikalefx Level 1
                                  im not sure what you mean, but just think in IF statements. if you can talk it out with If elses, then it will work, otherwise, im not sure what you mean.
                                  • 14. Re: Newbie - dependable comboBox Flash 8
                                    NcCMbC Level 1
                                    Okay, thanks for you help. I have lot to learn before I'll be able to get this working the way I need, but you have provided a fantastic start. I'm sure the other newbie's will appreciate it as well.
                                    • 15. Re: Newbie - dependable comboBox Flash 8
                                      NcCMbC Level 1
                                      I've been trying for days. I've gotten close, I can select an item in the first box and a new list appears in the second, but now I cannot get it to perform an action - goto and stop. The data field clears after the second selection and says undefined. Here is my code - please excuse the ignorance.

                                      my_cb.addItem({data:1, label:"label1"});
                                      my_cb.addItem({data:2, label:"label2"});
                                      my_cb.addItem({data:3, label:"label3"});
                                      my_cb.addItem({data:4, label:"label4"});

                                      listenerObject = new Object();
                                      listenerObject.change = function(eventObject:Object){

                                      trace(eventObject.target.selectedItem.data);

                                      myVar = eventObject.target.value;


                                      listenerobject = new Object();
                                      listenerobject.change = function(eventobject:Object) {
                                      trace(eventobject.target.selectedItem.label);
                                      trace(eventobject.target.selectedItem.data);
                                      };
                                      main_cb.addEventListener("change",lo); // <- cb is the comobox instance

                                      main_cb.dataProvider = second_cb.dataProvider = lo;

                                      if (myVar = 1) {
                                      my_cb1.removeAll(my_cb1)
                                      my_cb1.addItem({data:one, label:"1stlabel1"});
                                      my_cb1.addItem({data:two, label:"1stlabel2"});
                                      my_cb1.addItem({data:three, label:"1stlabel3"});
                                      my_cb1.addItem({data:four, label:"1stlabel4"});
                                      gotoAndStop(my_cb1.value);
                                      }//end if
                                      else if (myVar = 2) {

                                      my_cb1.addItem({data:one, label:"2ndlabel1"});
                                      my_cb1.addItem({data:two, label:"2ndlabel2"});
                                      my_cb1.addItem({data:three, label:"2ndlabel3"});
                                      my_cb1.addItem({data:four, label:"2ndlabel4"});
                                      gotoAndStop(my_cb1.value);
                                      }//end if
                                      else if (myVar = 3) {

                                      my_cb1.addItem({data:one, label:"3rdlabel1"});
                                      my_cb1.addItem({data:two, label:"3rdlabel2"});
                                      my_cb1.addItem({data:three, label:"3rdlabel3"});
                                      my_cb1.addItem({data:four, label:"3rdlabel4"});
                                      gotoAndStop(my_cb1.value);
                                      }//end if
                                      else if (myVar = 4) {

                                      my_cb1.addItem({data:one, label:"4thlabel1"});
                                      my_cb1.addItem({data:two, label:"4thlabel2"});
                                      my_cb1.addItem({data:three, label:"4thlabel3"});
                                      my_cb1.addItem({data:four, label:"4thlabel4"});
                                      gotoAndStop(my_cb1.value);
                                      }//end if
                                      }// end listener
                                      my_cb.addEventListener("change", listenerObject)
                                      my_cb1.addEventListener("change", listenerObject)
                                      • 16. Re: Newbie - dependable comboBox Flash 8
                                        OblivionKnight

                                        Hi,


                                        I'm pretty much trying to do the same, but it appears a lot of the code and snippets that were being passed back and forth are not available. Making this a hard thread to follow.

                                         

                                        Can the author please share their solution.


                                        Thanks.