Skip to main content
Participating Frequently
July 11, 2013
Answered

comboBox - iterate through dropdown elements?

  • July 11, 2013
  • 1 reply
  • 2498 views

I need to subdivide a large list of elements in a comboBox into smaller groups in Flash. Is there anyway to loop throught the elements and set te background color of each element to a value in the dataProvider object?

I can run through the loop using myPoS_combobox.dropdown

var ddList = myPoS_combobox.dropdown

for(var propertyName in ddList) {

     trace(ddList[propertyName])

}

But I can't seem to get to the individual elements, much less change their properties.

THANKS!

This topic has been closed for replies.
Correct answer kglad

I don't know if I have explained myself adequately.

I want to programatically change the background of each item in the combobox to a specific color. I have attempted to use the technique you stated above, but all it does is change the background color of the combobox in it's closed state. I need to loop through each element (I am doing this on the OPEN handeler). I can't seem to acess any cell in particular.


if you want to change the background colors in the list component portion of the combobox, you'll need to use a cellrenderer: http://help.adobe.com/en_US/ActionScript/3.0_UsingComponentsAS3/WS5b3ccc516d4fbf351e63e3d118a9c65b32-7fd4.html

1 reply

kglad
Community Expert
Community Expert
July 11, 2013

loop through myPoS_combobox'es dataProvider property.

Participating Frequently
July 11, 2013

I can do that, but what I need to do is change individual cell background colors. Here is my data provider:

private var PoS_label_array:Array = new Array(

                    {label:"SN\tsubject noun", data:"SN", myColor:ShurleyColors.shurleyBlue},

                    {label:"CSN\tcomp subject noun", data:"CSN", myColor:ShurleyColors.shurleyBlue},

                    {label:"OP\tobject of the preposition noun", data:"OP", myColor:ShurleyColors.shurleyBlue},

                    {label:"COP\tcomp object of the preposition noun", data:"COP", myColor:ShurleyColors.shurleyBlue},

                    {label:"DO\tdirect object noun", data:"DO", myColor:ShurleyColors.shurleyBlue},

                    {label:"CDO\tcomp direct object noun", data:"CDO", myColor:ShurleyColors.shurleyBlue},

                    {label:"IO\tindirect object noun", data:"IO", myColor:ShurleyColors.shurleyBlue},

                    {label:"CIO\tcomp indirect object noun", data:"CIO", myColor:ShurleyColors.shurleyBlue},

                    {label:"PrN\tpredicate noun", data:"PrN", myColor:ShurleyColors.shurleyBlue},

                    {label:"CPrN\tcomp predicate noun", data:"CPrN", myColor:ShurleyColors.shurleyBlue},

                    {label:"OCN\tobject compliment noun", data:"OCN", myColor:ShurleyColors.shurleyBlue},

                    {label:"COCN\tcomp object compliment noun", data:"COCN", myColor:ShurleyColors.shurleyBlue},

                    /* PRONOUNS */

                    {label:"SP\tsubject pronoun", data:"SP", myColor:ShurleyColors.shurleyPurple},

                    {label:"CSP\tcomp subject pronoun", data:"CSP", myColor:ShurleyColors.shurleyPurple},

                    {label:"OPP\tobject of the prep pronoun", data:"OPP", myColor:ShurleyColors.shurleyPurple},

                    {label:"DO\tdirect object pronoun", data:"DO", myColor:ShurleyColors.shurleyPurple},

                    {label:"IO\tindirect object pronoun", data:"IO", myColor:ShurleyColors.shurleyPurple},

                    {label:"OCP\tobject compliment pronoun", data:"OCP", myColor:ShurleyColors.shurleyPurple},

                    /* VERBS */

                    {label:"V\tverb", data:"V", myColor:ShurleyColors.shurleyRed},

                    {label:"CV\tcomp verb", data:"CV", myColor:ShurleyColors.shurleyRed},

                    {label:"V-t\tverb transitive", data:"V-t", myColor:ShurleyColors.shurleyRed},

                    {label:"CV-t\tcomp verb transitive", data:"CV-t", myColor:ShurleyColors.shurleyRed},

                    {label:"CV\tcompound verb", data:"CV", myColor:ShurleyColors.shurleyRed},

                    {label:"LV\tlinking verb", data:"LV", myColor:ShurleyColors.shurleyRed},

                    /* DESCRIPTIVE */

                    {label:"Adv\tadverb", data:"Adv", myColor:ShurleyColors.shurleyPink},

                    {label:"Adj\tadjective", data:"Adj", myColor:ShurleyColors.shurleyGreen},

                    {label:"CAdj\tcomp adjective", data:"CAdj", myColor:ShurleyColors.shurleyGreen},

                    {label:"PNA\tpos noun adjective", data:"PNA", myColor:ShurleyColors.shurleyGreen},

                    {label:"PPA\tpos pro adjective", data:"PPA", myColor:ShurleyColors.shurleyGreen},

                    {label:"A\tarticle adjective", data:"A", myColor:ShurleyColors.shurleyGreen},

                    {label:"OCA\tobject compliment adjective", data:"OCA", myColor:ShurleyColors.shurleyGreen},

                    {label:"COCA\tcomp object compliment adjective", data:"COCA", myColor:ShurleyColors.shurleyGreen},

                    {label:"PA\tpredicate adjective", data:"PA", myColor:ShurleyColors.shurleyGreen},

                    {label:"CPA\tcomp predicate adjective", data:"CPA", myColor:ShurleyColors.shurleyGreen},

                    /*  */

                    {label:"P\tpreposiiton", data:"P", myColor:ShurleyColors.shurleyOrange},

                    {label:"C\tconjunction", data:"C", myColor:ShurleyColors.shurleyDarkGray},

                    {label:"I\tinterjection", data:"I", myColor:ShurleyColors.shurleyLightGray}

                    );


What I want to do is se the cells of the dropdown to the myColor property in the data provider.

kglad
Community Expert
Community Expert
July 11, 2013

enable their textField.textField background and assign their backgroundColor