Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

comboBox - iterate through dropdown elements?

New Here ,
Jul 11, 2013 Jul 11, 2013

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!

TOPICS
ActionScript
2.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 11, 2013 Jul 11, 2013

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

Translate
Community Expert ,
Jul 11, 2013 Jul 11, 2013

loop through myPoS_combobox'es dataProvider property.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 11, 2013 Jul 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 11, 2013 Jul 11, 2013

enable their textField.textField background and assign their backgroundColor

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 11, 2013 Jul 11, 2013

OK, is textField.textField a property of what exactly?

If I am iterating through the myCombobox.dropdown, which is an object type List, and has a specific length, I still dont know how to get to each "cell" in the dropdown.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 11, 2013 Jul 11, 2013

your combobox:


myCombobox.textField.textField.background = true;

myCombobox.textField.textField.border = true;

myCombobox.addEventListener(Event.CHANGE,cbF);

function cbF(e:Event):void {

   e.target.textField.textField.backgroundColor = e.target.selectedItem.myColor;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 11, 2013 Jul 11, 2013

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 11, 2013 Jul 11, 2013

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...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 11, 2013 Jul 11, 2013

That is making my head hurt. Thanks for the link.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 11, 2013 Jul 11, 2013

i agree.  it's not the easiest thing in the world to use.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 17, 2013 Jul 17, 2013

If you actuallt understand the custom cellRenderer process, could you briefly explain the structure and how implementation works. I have read as many articles as I can find, but I guess I just have a fundamental misunderstanding of where the cellRenderer fits, what it replaces, and how much actual class overwriting/inheritence I am going to have to do.

All I want to do is be able to dynamically change the background color of the fields in a combobox based on values in the dataProvider, and maybe put the row labels into columns based on values in the dataProvider.

example

  • i1     item one
  • i1a   item one a
  • i1b   item one b
  • i2     item two
  • i3     item three
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 19, 2013 Jul 19, 2013

I figured it out. Thanks. It took some fiddling, for sure, but I got ahold of the elements that I needed.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 19, 2013 Jul 19, 2013
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 11, 2013 Jul 11, 2013

if I try and access the Nth index of dropdown I get this error.

for (var i = 0; i<ddList.length; i++){

                                        trace(ddList)

}

"ReferenceError: Error #1069: Property 0 not found on fl.controls.List and there is no default value."



Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 11, 2013 Jul 11, 2013

Does that make sense?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines