A Flash Developer Resource Site

Results 1 to 20 of 20

Thread: How to prevent combobox displaying item 0 in the dropdown list

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Location
    Pierrefonds, QC Canada
    Posts
    13

    How to prevent combobox displaying item 0 in the dropdown list

    Hello there!

    I'm looking for a workaround preventing a ComboBox displaying item #0 in the dropdown list.

    Example:

    Items in the CB:
    "Choose...", "" (#0, appears as selectedItem at start)
    "label 1", "data 1"
    "label 2", "data 2"
    "label 3", "data 3"

    When clicked, the CB displays the four items in the dropdown list.
    That's bad!

    I just want it to display in the dropdown list:
    "label 1", "data 1"
    "label 2", "data 2"
    "label 3", "data 3"

    Repeating item #0 in the the dropdown list is annoying and useless.

    I thank you in advance for your help!!!

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    This works with the CS6 combobox

    PHP Code:
    theComboBox.addItem({label:"Label 1"data:1});
    theComboBox.addItem({label:"Label 2"data:2});
    theComboBox.addItem({label:"Label 3"data:3});

    setText();

    function 
    setText():Void
    {
        
    theComboBox.textField.text "Choose";
    }


    var 
    comboChange:Object = new Object();
    comboChange.change = function(comboChanges:Object)
    {
        var 
    getClicked:String comboChanges.target.selectedItem.label;

        
    setText();

        
    trace(getClicked);
    };
    theComboBox.addEventListener("change",comboChange);


    var 
    comboClose:Object = new Object();
    comboClose.close = function(comboClosed:Object)
    {
        
    setText();
    };
    theComboBox.addEventListener("close",comboClose); 
    obviously use your own or mine naming conventions to test

  3. #3
    Junior Member
    Join Date
    Dec 2012
    Location
    Pierrefonds, QC Canada
    Posts
    13
    Thank you very much "fruitbeard"!

    I am using AS2 in Flash 10 Pro (CS4).
    Do you think this will work?

    Anyway I'll give it a try, for sure!

  4. #4
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    in cs4 just click actionscript 2.0 and yea

  5. #5
    Junior Member
    Join Date
    Dec 2012
    Location
    Pierrefonds, QC Canada
    Posts
    13
    Alloy Bacon : ???????
    Sorry but your answer isn't relevant or something is missing...

  6. #6
    Junior Member
    Join Date
    Dec 2012
    Location
    Pierrefonds, QC Canada
    Posts
    13
    To "fruitbeard":

    For an unknown reason, I have been unable to post my reply which has been rejected by the system for more than a week!
    Even moderator Brad Jones wasn't able to post using his privileges!!!

    That's the reason why I send my reply in an attached text document.

    Sorry for the inconvenient...

    Best regards,

    Gerard
    Attached Files Attached Files

  7. #7
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    trouble posting also.rarrar.txt

    you should try attaching your fla, easier for us to see, and associated files
    Last edited by fruitbeard; 09-03-2017 at 10:15 AM.

  8. #8
    Junior Member
    Join Date
    Dec 2012
    Location
    Pierrefonds, QC Canada
    Posts
    13
    OK
    Just post your solution as I did (attached text document).
    Thanks!!!

  9. #9
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    It is CS5, as low as I can go.

  10. #10
    Junior Member
    Join Date
    Dec 2012
    Location
    Pierrefonds, QC Canada
    Posts
    13
    I cannot open the .fla
    But I can open the .swf and I see it works!
    Could you please copy the code in a text file so I can see it?
    Many thanks for your efforts!
    Best,
    Gerard

  11. #11
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    You will need somebody to save it as CS4 for you, I can only save a s low as CS5.
    You could also decompile it maybe.

    I can not post the file as I am having problems too, however, all the code you need is within the previous posts.

    Maybe Alloy can save it as CS4 for you seeing as he seemed to get it to work in CS4

  12. #12
    Junior Member
    Join Date
    Dec 2012
    Location
    Pierrefonds, QC Canada
    Posts
    13
    Why couldn't you copy all the code in a simple text file which you attach to your post?
    It will be so simple...

  13. #13
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

  14. #14
    Junior Member
    Join Date
    Dec 2012
    Location
    Pierrefonds, QC Canada
    Posts
    13
    Thank you very much!
    I'll give this a try this very evening...

  15. #15
    Junior Member
    Join Date
    Dec 2012
    Location
    Pierrefonds, QC Canada
    Posts
    13
    Hello!

    Using the code you post, I've been able to rebuild in CS4 the .fla.
    Your code is working nice.
    But (there's always a "but"!), if you press a character key or the command key, ComboBox text disappear leaving a blank field.
    ComboBox is functional anyway but user could be a bit surprised by this bug.
    Do you think there will be some workaround to eliminate it?
    If yes, the job will be perfect...

    Anyway, I thank you very much for your help and wish you a very nice day!

  16. #16
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Your bug sounds unusual and hard to emulate. would need to see your files.
    I doubt it is the code that is doing it unless some of your code is creating the anomaly.

  17. #17
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    I see what you mean, thats probably due to the allowing of keyboard commands within the combobox, perhaps they can be disabled.

    this can tame it down a bit though.

    play around with some listeners etc

  18. #18
    Junior Member
    Join Date
    Dec 2012
    Location
    Pierrefonds, QC Canada
    Posts
    13
    Good workaround, thank you.
    I am looking now for a solution to make the CB completely unresponsive to any input from the Keyboard...
    Of course, I'll keep you informed.

  19. #19
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    setting focus to the text field, if you use one that is, or you could put a small unused text field somewhere and use the selcted line.

    still having posting issues
    Attached Files Attached Files

  20. #20
    Junior Member
    Join Date
    Dec 2012
    Location
    Pierrefonds, QC Canada
    Posts
    13
    Hello!

    No doubt, this is an improvement. Thanks!

    The application in which I'm planning to use ComboBoxes "without repeat" contains 36 CB!!!
    I'm not fluent enough in AS2 to build something very complex.
    But I was thinking of altering or creating a Class from the scratch, say build a "private class" which could fix for any ComboBox I use in this app the following states/properties:
    - unresponsive to keyboard
    - not repeating item 0 in the dropdown list
    - create a "polyvalent" listener...
    Do you think this will be possible?

Tags for this Thread

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