Copy link to clipboard
Copied
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!
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
Copy link to clipboard
Copied
loop through myPoS_combobox'es dataProvider property.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
enable their textField.textField background and assign their backgroundColor
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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;
}
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
That is making my head hurt. Thanks for the link.
Copy link to clipboard
Copied
i agree. it's not the easiest thing in the world to use.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
I figured it out. Thanks. It took some fiddling, for sure, but I got ahold of the elements that I needed.
Copy link to clipboard
Copied
you're welcome.
Copy link to clipboard
Copied
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."
Copy link to clipboard
Copied
Does that make sense?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now