A Flash Developer Resource Site

Page 2 of 3 FirstFirst 123 LastLast
Results 21 to 40 of 49

Thread: ComboBoxes :(

  1. #21
    Senior Member
    Join Date
    Jul 2002
    Location
    California
    Posts
    125
    Thanks for the thought!

  2. #22
    Senior Member
    Join Date
    May 2001
    Posts
    110
    Hahaha last question I promise this time...

    I'm trying to do an "if" statement based on one of the results. basiacally if the value of combox1 is 1.1 keep the mc._visible fasle. If it's anything else make it visible.

    gif(varComboBox1.getValue == "1.1")
    comboLabel2._visible = true;
    else
    comboLabel2._visible = false;

  3. #23
    Senior Member
    Join Date
    Jul 2002
    Location
    California
    Posts
    125
    No problem. This is way more fun than what I'm supposed to be working on.

    .getValue is used to figure out what the user chose in the comboBox. And since you already used .getValue to create the variable varComboBox1, all you need to do is refer to varComboBox1.

    Also "gif" should be "if." And I put some curly bracket things in there too. If this doesn't work, let me know.

    Code:
    if(varComboBox1 == "1.1") {
     comboLabel2._visible = true;
    }
    else {
     comboLabel2._visible = false;
    }

  4. #24
    Senior Member
    Join Date
    May 2001
    Posts
    110
    Ok it isn't working. is.getvalue getting the Label or the Data of the comboBox1? I want it to get the Data. Also the if statement eisn't working and I'm not quite sure why.

  5. #25
    Senior Member
    Join Date
    Jul 2002
    Location
    California
    Posts
    125
    From the ActionScript dictionary: [quote].getValue returns the text in the field at the top of the combo box, if the combo box is editable. If the combo box is static (not editable), this method returns the data associated with the selected item, or the label of the item if no data is associated.[/qoute]

    If you attach your file again, I'll take a look at it.

  6. #26
    Senior Member
    Join Date
    May 2001
    Posts
    110
    It's a 2004 file. Is that going to be an issue? It's also too big to attach.

  7. #27
    Senior Member
    Join Date
    May 2001
    Posts
    110
    Here is my complete code
    Code:
    comboBox2._visible = false
    comboBox5._visible = false
    comboBox6._visible = false
    comboBox7._visible = false
    businessLayout._visible = false
    comboLabel2._visible = false
    
    estLoadVars = new LoadVars();
    
    function comboBox1Change() {
     varcomboBox1 = comboBox1.getValue();
     myLoadVars.varComboBox1 = varComboBox1;
    }
    function comboBox2Change() {
     varcomboBox2 = comboBox2.getValue();
     myLoadVars.varComboBox2 = varComboBox2;
    }
    function comboBox3Change() {
     varcomboBox3 = comboBox3.getValue();
     myLoadVars.varComboBox3 = varComboBox3;
    }
    function comboBox4Change() {
     varcomboBox4 = comboBox4.getValue();
     myLoadVars.varComboBox4 = varComboBox4;
    }
    function comboBox5Change() {
     varcomboBox5 = comboBox5.getValue();
     myLoadVars.varComboBox5 = varComboBox5;
    }
    function comboBox6Change() {
     varcomboBox6 = comboBox6.getValue();
     myLoadVars.varComboBox6 = varComboBox6;
    }
    function comboBox7Change() {
     varcomboBox7 = comboBox7.getValue();
     myLoadVars.varComboBox7 = varComboBox7;
    }
    if(varcomboBox1 == "1.1") {
     businessLayout._visible = true;
    }else {
     businessLayout._visible = false;
    }
    stop();

  8. #28
    Senior Member
    Join Date
    Jul 2002
    Location
    California
    Posts
    125
    Cool. That's what I needed. I think you need to move
    Code:
    if(varcomboBox1 == "1.1") {
     businessLayout._visible = true;
    }else {
     businessLayout._visible = false;
    }
    to the function that controls what happens when your user clicks the submit button. Does that make sense?

  9. #29
    Senior Member
    Join Date
    May 2001
    Posts
    110
    Still not working. Could this have to do with a change handler or lack thereof? I'm good enough at code to tell you if there's one in there or not. Oh about moving the function to the button. It didn't work either, though I don't want that particular thing on the button anyways. thanks again for all your help.

  10. #30
    Senior Member
    Join Date
    Jul 2002
    Location
    California
    Posts
    125
    Yup. Sorry, I was assuming that you wanted all of this to happen when Submit was clicked. But if you want it to happen on some other event, you need to put
    Code:
    if(varcomboBox1 == "1.1") {
     businessLayout._visible = true;
    }else {
     businessLayout._visible = false;
    }
    in the appropriate function.

    For example, if you want the movie clips to become visible/invisible whenever a user changes their selection in any of the combo boxes, you could create this change handler:
    Code:
    function myChangeHandler() {
     varcomboBox1 = comboBox1.getValue();
     myLoadVars.varComboBox1 = varComboBox1;
     varcomboBox2 = comboBox2.getValue();
     myLoadVars.varComboBox2 = varComboBox2;
     varcomboBox3 = comboBox3.getValue();
     myLoadVars.varComboBox3 = varComboBox3;
     //etc. for all 7 boxes
     myLoadVars.varComboBox1 = varComboBox1;
     myLoadVars.varComboBox2 = varComboBox2;
     myLoadVars.varComboBox3 = varComboBox3;
     //etc. for all 7 boxes
     if(varcomboBox1 == "1.1") {
      businessLayout._visible = true;
     }else {
      businessLayout._visible = false;
     }
     //add other if statements for other comboboxes as needed
    }
    For this to work, all 7 of your comboxes would have to have myChangeHandler for their change handler. And you'd delete the other change handlers - comboBox1Change(), etc.

    Also, I just noticed that you create the LoadVars object with
    Code:
    estLoadVars = new LoadVars();
    but you refer to myLoadVars in your code. Make sure to change myLoadVars in your code to estLoadVars.

    Let me know if it works or not...

  11. #31
    Senior Member
    Join Date
    May 2001
    Posts
    110


    Is it me or does the second half of your code repeat itself?
    Code:
    function myChangeHandler() {
    varcomboBox1 = comboBox1.getValue();
    myLoadVars.varComboBox1 = varComboBox1;
    Code:
     myLoadVars.varComboBox1 = varComboBox1;
    My head hurts. thanks for the help though

  12. #32
    Senior Member
    Join Date
    May 2001
    Posts
    110
    Using just one comboBox to make the code easier to understand, here is what I have currently

    Code:
    comboBox2._visible = false
    
    myLoadVars = new LoadVars();
    
    function myChangeHandler() {
    varcomboBox1 = comboBox1.getValue();
    myLoadVars.varcomboBox1 = varcomboBox1;
    
    myLoadVars.varcomboBox1 = varcomboBox1;
    if(varcomboBox1 == "1.1") {
    	comboBox2._visible = true;
    }
    }
    stop ()

  13. #33
    Senior Member
    Join Date
    Jul 2002
    Location
    California
    Posts
    125
    Oops. Yes, the 2nd half of my code repeats. Sorry about that - I need more sleep. I should have just said:
    Code:
    function myChangeHandler() {
     varcomboBox1 = comboBox1.getValue();
     myLoadVars.varComboBox1 = varComboBox1;
     varcomboBox2 = comboBox2.getValue();
     myLoadVars.varComboBox2 = varComboBox2;
     varcomboBox3 = comboBox3.getValue();
     myLoadVars.varComboBox3 = varComboBox3;
     //etc. for all 7 boxes
     if(varcomboBox1 == "1.1") {
      businessLayout._visible = true;
     }else {
      businessLayout._visible = false;
     }
     //add other if statements for other comboboxes as needed
    }
    So your version for just the one combo box would be:
    Code:
    comboBox2._visible = false
    
    myLoadVars = new LoadVars();
    
    function myChangeHandler() {
     varcomboBox1 = comboBox1.getValue();
     myLoadVars.varcomboBox1 = varcomboBox1;
     if(varcomboBox1 == "1.1") {
      comboBox2._visible = true;
     }
    }
    stop();
    And remember to change your combo box's change handler to myChangeHandler.

  14. #34
    Senior Member
    Join Date
    May 2001
    Posts
    110
    This works perfect. Now I do have another question though. How do I mix this into what we had before? I still want to send the values to an asp page. I just ALSO wanted to check the value locally and perform an action. It seems like doing it this way is either one or the other? Here is my current code on frame one. I don't know if the code on the button is relevant still or not?

    Code:
    comboBox2._visible = false
    comboBox1.addEventListener ("change", myChangeHandler);
    myLoadVars = new LoadVars();
    
    function myChangeHandler() {
     varcomboBox1 = comboBox1.getValue();
     myLoadVars.varcomboBox1 = varcomboBox1;
     if(varcomboBox1 == "1.1") {
      comboBox2._visible = true;
     }
    }
    stop();

  15. #35
    Senior Member
    Join Date
    May 2001
    Posts
    110
    Ok... I THINK everything is working. I just need a developer to write me a test ASP page that tells me if it is receiving variables or not. Here is my finished code...
    Code:
    comboBox2._visible = false
    comboBox5._visible = false
    comboBox6._visible = false
    comboBox7._visible = false
    businessLayout._visible = false
    comboLabel2._visible = false
    
    comboBox1.addEventListener ("change", myChangeHandler);
    
    function myChangeHandler() {
    varcomboBox1 = comboBox1.getValue();
    myLoadVars.varcomboBox1 = varcomboBox1;
    if(varcomboBox1 == "0") {
    	comboBox2._visible = false;
    	comboBox5._visible = false;
    	comboBox6._visible = false;
    	comboBox7._visible = false;
    	comboLabel2._visible = false;
    	businessLayout._visible = false;
    }else if(varcomboBox1 == "1.1") {
    	comboBox2._visible = false;
    	comboBox5._visible = false;
    	comboBox6._visible = false;
    	comboBox7._visible = false;
    	comboLabel2._visible = false;
    	businessLayout._visible = false;
    }else if(varcomboBox1 == "1.2") {
    	comboBox2._visible = false;
    	comboBox5._visible = true;
    	comboBox6._visible = true;
    	comboBox7._visible = true;
    	comboLabel2._visible = false;
    	businessLayout._visible = true;
    }else if(varcomboBox1 == "1.3") {
    	comboBox2._visible = true;
    	comboBox5._visible = true;
    	comboBox6._visible = true;
    	comboBox7._visible = true;
    	comboLabel2._visible = true;
    	businessLayout._visible = true;
    }
    }
    myLoadVars = new LoadVars();
    function comboBox1Change() {
     varcomboBox1 = comboBox1.getValue();
     myLoadVars.varcomboBox1 = varcomboBox1;
    }
    function comboBox2Change() {
     varcomboBox2 = comboBox2.getValue();
     myLoadVars.varcomboBox2 = varcomboBox2;
    }
    function comboBox3Change() {
     varcomboBox3 = comboBox3.getValue();
     myLoadVars.varcomboBox3 = varcomboBox3;
    }
    function comboBox4Change() {
     varcomboBox4 = comboBox4.getValue();
     myLoadVars.varcomboBox4 = varcomboBox4;
    }
    function comboBox5Change() {
     varcomboBox5 = comboBox5.getValue();
     myLoadVars.varcomboBox5 = varcomboBox5;
    }
    function comboBox6Change() {
     varcomboBox6 = comboBox6.getValue();
     myLoadVars.varcomboBox6 = varcomboBox6;
    }
    function comboBox7Change() {
     varcomboBox7 = comboBox7.getValue();
     myLoadVars.varcomboBox7 = varcomboBox7;
    }
    And with the code on the button it should work.

  16. #36
    Senior Member
    Join Date
    May 2001
    Posts
    110
    Tada, just wanted to say thanks again. It is working 100% right now. I was only able to get his job done because of you. Thank you again. I would lik to send you the finished file and I will if you email me your email adress. thanks again

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

  18. #38
    Senior Member
    Join Date
    May 2001
    Posts
    110
    Can you help me out with one more thing?

    I have a submit button on the stage. Amongst the other things I have coded for it I would like it to check that at least 3 variables have been passed. Is this possible? Basically I would want something like...

    if variables > 3 continue
    else play mc.

    Can you tell me how to code this?

    Hmmmm. Actually I don't know if it's possible to check that all ._visible comboBoxes are passing a variable? I have some comboBoxes that are only visible depending on answers so I can't just make it check all the variables. Is this possible?

    I would rather do the second option if it's all equal.

  19. #39
    Senior Member
    Join Date
    Jul 2002
    Location
    California
    Posts
    125
    You could set up all of your combo boxes so that their first line is "Select One:" or something like that. That way if varComboBox1="Select One:" you know that the user didn't select anything. So you could use this in the code for your submit button:
    Code:
    if (myComboBox1._visible == true) {   
     if (varComboBox1 == "Select One:") {  //User hasn't selected anything
      //Some code showing user a message saying they have to select.
     }
    }
    if (myComboBox2._visible == true) {   
     if (varComboBox2 == "Select One:") {  //User hasn't selected anything
      //Some code showing user a message saying they have to select.
     }
    }
    //And so on for each of the combo boxes.
    //Code that really submits goes here. The user will only get to this point if they've selected everything they're supposed to.
    Does that make sense?

  20. #40
    Senior Member
    Join Date
    May 2001
    Posts
    110
    hahahahaha yeah it does!!!! let me try and I'll get back to you. thanks...

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