flex - dynamically generate ComboBox name -
I have a script that parses some complex XML when the XML element is of a certain type, then this box Creates a combo box using the XML element to populate. Then I want to see all the values of all the generated comboboxes for their correct answers (which is also the information stored in the XML file). While creating ComboBoxes, I added an "id" property though, it seems that I can not use them:
Dynamic Query.ID.Satched item.Labelfield
To check the answers. However, I'm able to get the Label field if I know the name of the variable used to create the combo box.
dynamicQuestion.selectedItem.labelField
This indicates (me) that I need to dynamically generate variable names because I am new to comboboxes I'm creating examples. But how do I dynamically generate a variable name? If I use
var this string: string = "box" + boxcount; Var newbox: combo box = this box as combo box; I get an underlying rape error. I also tried to change the creation statement in a statement, which argued, "this box," but it does not work either conceptually. It seems quite simple, but I'm having a hard time practicing it seems that the combo box is generated by creating a box using the ID script (e.g., verb this box). How do I generate this name in a dynamic way?
Use an array as Stephen's suggestion. If you want to use string identifier, then you can create an object and use it as an associate array.
var combos: Object = {}; Var Boxcount: Number = 1; Var this box: string = "box" + boxcount; // You can store Cambobox in the object by using the following syntax combos [this box] = new combo box (); // or combos.box2 = new combo box (); // or comb ["box 3"] = new combo box (); Trace (combos.box1.selectedItem.labelField); Trace (combos.box2.selectedItem.labelField); Trace (combos.box3.selectedItem.labelField);
Comments
Post a Comment