开发者

Array Syntax to populate Flash combobox

I've got an array that looks like this, iterating through:

(languageArray[i].languageName);  //e.g. "French"
(languageArray[i].languageCode);  //e.g. "fre"

I'm trying to populate a fl.controls.ComboBox dataProvider with this array. What 开发者_如何学运维I want to do is set the labelfield, as shown in the documentation:

myComboBox.dataProvider = dp;
myComboBox.labelField = "firstName";

For my code:

myComboBox.dataProvider = dp;
myComboBox.labelField = languageName;
myComboBox.data = languageCode;

In other words I want the name to be displayed, and the 'data' to be the code, which will be called when I click on the item. But the labelField is not the same as "French". How do I create the two fields in the array such that I can designate the first as labelField and the second as data?

Thanks.


As @Jens answered,

myComboBox.labelField = "languageName";
myComboBox.dataField = "languageCode";

Should correct this. The labelField and data properties are looking for a String to later use to reference the object's property.

Without the quotes, You're telling it to look in the future for an Object's (whatever languageName evaluates to in this context) property. (IE: if languageName evaluates to "Class 0xAB12CB00", or a similar useless toString in this context, it will attempt to find object["Class 0xAB12CB00"] and use that as the labelField).


myComboBox.labelField = "languageName";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜