A Flash Developer Resource Site

Page 1 of 3 123 LastLast
Results 1 to 20 of 49

Thread: ComboBoxes :(

  1. #1
    Senior Member
    Join Date
    May 2001
    Posts
    110

    ComboBoxes :(

    Hey guys, I am embarrassed to say I don't know how to use a ComboBox. I'm setting up a form with about 8 ComboBoxes. Based on the answers a _mc will load. Can anyone please help me with this? I have the layout and the info all in,I just need to learn how to make it work.

    Thanks in advance

    Michael

  2. #2
    Senior Member
    Join Date
    May 2001
    Posts
    110
    I can ask nicer.... please

  3. #3
    Senior Member
    Join Date
    Jul 2002
    Location
    California
    Posts
    125
    Well, for starters you can use myComboBox.getValue() to find out what your user has selected. From there, you can write if/then statements based on what the user has selected. That's pretty general - is that the sort of answer you're looking for? If not, give me more details, and I'll try to help.

    Oh, and you'll probably want to create a change handler function for your combo box - that's a function that gets called whenever something is changed in your combo box, such as when the user selects something. Holler if you need more details about this.

    Good luck!
    Last edited by tada; 09-08-2003 at 02:54 PM.

  4. #4
    Senior Member
    Join Date
    May 2001
    Posts
    110
    Thanks so much. Here is the file. Basically it is seven questions and based on the answers, a different _mc will load. I dont know how to even begin coding this. I know a decent amount of flash but have never had to use a CoboBox yet. I feel like such a rookie Here is the file. any pointers are appreciated.
    Attached Files Attached Files

  5. #5
    Senior Member
    Join Date
    Jul 2002
    Location
    California
    Posts
    125
    Ha! I know almost nothing about Flash except for forms.

    I have to work right now, but I'll take a look at this on my lunch hour and get back to you some time today. Hang in there!

  6. #6
    Senior Member
    Join Date
    May 2001
    Posts
    110
    hahaha thanks, with my design prowess and your form building we could take over the world!!!! Or maybe just work regular jobs and pay bills but whatever

    Thanks by the way.
    Last edited by circle282; 09-08-2003 at 03:09 PM.

  7. #7
    Senior Member
    Join Date
    Jul 2002
    Location
    California
    Posts
    125
    The first thing you need to do is give your combo boxes and your button instance names. You can do that by clicking on the combo box or button, and then opening the Properties panel. (In the top left of the panel, you'll see the box where you enter the instance name.)

    After you do that, add another layer and name it Actions. From this layer, open the Actions panel. This is where you're going to put all of the actionscript that will keep track of what's been selected in the combo boxes, and what will happen when your user clicks the Submit button. You'll want to be in Expert mode so you can just type in the actionscript directly. If you don't know how to switch from Normal mode to Expert mode, let me know...

    Now create some variables that will keep track of what has been selected in each combo box. Type this in your Actions panel:

    Code:
    var varComboBox1 = myComboBox1.getValue();
    myComboBox1 is the instance name you created for your first combo box. varComboBox1 can named differently if you want. Keep doing this for all of the combo boxes.

    myComboBox1.getValue() will return the label of the item selected in the combox box. So in your example, if the user selected New Business in the first combo box, varComboBox1 would be "New Business".

    Now for the part that happens when the user presses Submit. Type something like this in the Actions panel:

    Code:
    if (varComboBox1=="New Business") {
     loadMovie("url",level/target[, variables]);
    }
    Of course, I don't know which movies you want to load when the user selects various combinations. Your if/then statements could get pretty ugly depending on how many movies you have to choose between. Holler if you want help with that part.

    I hope at least some of this makes sense, but I just had cheetos and coffee for lunch and my ability to communicate may have been affected for the worse. Let me know if I've confused you, and we'll get it figured out.

  8. #8
    Senior Member
    Join Date
    May 2001
    Posts
    110
    Well, I'm gonna sit down and finish this now... I'll let you know how it turns out. Thanks in adavance btw are you on msn?

  9. #9
    Senior Member
    Join Date
    May 2001
    Posts
    110
    Man, I'm sorry to keep bothering you... I realy thought this would be the time I got it right. Ok here is my code on frame one.

    Code:
    stop();
    var varComboBox1 = myComboBox1.getValue();
    and this is the code on my button

    Code:
    on (release){
    	if(varComboBox1 == "New Business")
    	loadMovie("text_files/documents_MOVIE.swf", "right");
    }

    The ComboBox instance name is "myComboBox1". this is the set-up that is not working. I've tried a bunch of different version and basically the problem seems to be with the ComboBox. The button code works fine once I take the "if" statement off. and I used similar code before. should I be doing ANYTHING else? I don't have a change handler set up, is that an issue? Also I don't have anything set up as "DATA" in the ComboBox. Thank you so much for helping me through this.

  10. #10
    Senior Member
    Join Date
    Jul 2002
    Location
    California
    Posts
    125
    Oops! My fault. Of course you need a change handler function for the combo box - otherwise how will it update varComboBox1 when the user selects something there? So make myComboBox1 have the change handler myComboBox1Change, and this should work:
    Code:
    var varComboBox1;
    function myComboBox1Change() {
     varComboBox1 = myComboBox1.getValue();
    }
    stop();
    (Leave the code for your button as is.)

    BTW, when you don't have anything for DATA in the comboBox, .getValue() just returns the label, so that shouldn't be a problem.

    And yes, I'm on MSN, but no, I can't use it at work (grrrr!) so flashkit is the best way to reach me. Don't worry about bothering me - after a hard day of not understanding ANYTHING else I'm working on, it's a nice ego boost to help someone with the couple of things I do know how to do. Mostly know. Sort of know. Can eventually figure out, anyway.

    Let me know if this works...

  11. #11
    Senior Member
    Join Date
    May 2001
    Posts
    110
    PERFECT!!! Now on to the IF scripts. I can handle that on my own though. Thanks so much. A JAVA developer here came over to help me out and he had it pretty much nailed but way too complicated

  12. #12
    Senior Member
    Join Date
    Jul 2002
    Location
    California
    Posts
    125
    You're welcome!

  13. #13
    Senior Member
    Join Date
    May 2001
    Posts
    110
    One huge thing I just thought of. How does this work if the ComboBoxes are in an mc?

  14. #14
    Senior Member
    Join Date
    Jul 2002
    Location
    California
    Posts
    125
    Basically, putting the comboBox in a movie clip just changes its path. So assuming your comboBox change handler isn't created in the movie clip, it will have to look like this:
    Code:
    function myComboBox1Change() {
     varComboBox1 = _root.myMovieClip.myComboBox1.getValue();
    }

  15. #15
    Senior Member
    Join Date
    May 2001
    Posts
    110
    Still cracking at it. I'll send you a copy when it's done

  16. #16
    Senior Member
    Join Date
    May 2001
    Posts
    110
    A blast from the past...

    How can I pass these collected variables to an asp page?

  17. #17
    Senior Member
    Join Date
    Jul 2002
    Location
    California
    Posts
    125

    Hello again...

    I use a LoadVars object:
    Code:
    myLoadVars = new LoadVars();
    varComboBox1 = myLoadVars.varComboBox1;
    myLoadVars.sendAndLoad("Some_ASP_Page.asp",myLoadVars,"POST");
    This sends the variable in MIME format, e.g., varComboBox1=this&varComboBox2=thatr&varComboBox3= theother

    I suggest using myLoadVars.sendAndLoad rather than myLoadVars.send. This is because myLoadVars.send will cause the asp page to open too, and be visible to the user. That's probably not what you want. The only way I've found to avoid this is to use myLoadVars.sendAndLoad.

    Good luck!

  18. #18
    Senior Member
    Join Date
    May 2001
    Posts
    110
    Ok, here is the code I currently have on frame one
    Code:
    var varcomboBox1;
    function comboBox1Change() {
     varcomboBox1 = comboBox1.getValue();
    }
    var varcomboBox2;
    function comboBox2Change() {
     varcomboBox2 = comboBox2.getValue();
    }
    var varcomboBox3;
    function comboBox3Change() {
     varcomboBox3 = comboBox3.getValue();
    }
    var varcomboBox4;
    function comboBox4Change() {
     varcomboBox4 = comboBox4.getValue();
    }
    var varcomboBox5;
    function comboBox5Change() {
     varcomboBox5 = comboBox5.getValue();
    }
    var varcomboBox6;
    function comboBox6Change() {
     varcomboBox6 = comboBox6.getValue();
    }
    var varcomboBox7;
    function comboBox7Change() {
     varcomboBox7 = comboBox7.getValue();
    }
    stop();
    And here is the code I have on my button
    Code:
    on (release){
    	getURL("url", "_blank", "POST");
    }
    What do I need to change to use your code?

  19. #19
    Senior Member
    Join Date
    Jul 2002
    Location
    California
    Posts
    125
    First create the LoadVars object. Put this before your combo box functions:
    Code:
    myLoadVars = new LoadVars();
    Then add your variables to the object. To do this, change your combo box functions this way:
    Code:
    function comboBox1Change() {
     varcomboBox1 = comboBox1.getValue();
     myLoadVars.varComboBox1 = varComboBox1;
    }
    //Do the same for boxes 2-7.
    Then add this to the function for your submit button:
    Code:
    myLoadVars.sendAndLoad("Some_ASP_Page.asp",myLoadVars,"POST");
    That way the variable will be sent to your ASP page when the user clicks submit.

  20. #20
    Senior Member
    Join Date
    May 2001
    Posts
    110
    Thank you very much. If you were local I'd buy you a 6 pack or something

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center