开发者

Generate dynamic Flex-ComboBoxes by Class-Properties

I have an Flex-Object with for example 3 properties.

myObj.prop1 myObj.prop2 myObj.prop3

I like to generate 3 Comboboxes to show the data. No problem if I do it hardcoded in sourcecode.

But how can I find the prop1 to prop3 at runtime?

If next time I have 5 properties with different name it should generate 5 combos.开发者_JAVA百科

Thanks for any help Jan


Take a look at this question which shows you how to get all the properties in an object. Then just loop over them:

for each(var id:String in myObj) {
  // create ComboBox
  var combo : ComboBox = new ComboBox
  addChild(combo);
}

It is unclear from your post how the properties in the myObj relate tot he ComboBoxes you want to create. It is also unclear how you will distinguish your custom properties from the generic properties of an Object.

When defining dynamic properties like this, I prefer to use a Dictionary instead of an Object; but that is just my preference. Objects will work fine too.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜