Figure 11-16. Labels and TextInput added
20. Give the ComboBox components the IDs osCombo, browserCombo, and experienceCombo.
We will be using ActionScript to create the options in each of the ComboBoxes. We??™ll do this by creating
an array that holds the label for each of the options; see Figure 11-17 for the code.
Figure 11-17. ActionScript for populating ComboBoxes
228
CHAPTER 11
As you can see in Figure 11-17, we are creating three variables: os, browser, and experience. Each of
these variables is an array. As we discussed in Chapter 7, an array is a kind of variable that can hold
multiple pieces of information. In each array, we create a set of data by placing the label and the data
that is associated with it in curly brackets. The entire data set for the array is surrounded by square
brackets. We place all of the code in a Script tag to separate it from the MXML.
21. Add this script to your MXML in the Source view above the Panel now.
22. Jumping back to the Design view, connect these
arrays to the ComboBoxes by placing the name of
the array, surrounded by curly brackets, into the
Data provider property of the ComboBoxes
(Figure 11-18). Each of the ComboBoxes has its
own array, with the array os populating the
osCombo, the browser array populating the
browserCombo, and the experience array populating
the experienceCombo.
As you connect the arrays, the width of the ComboBox
will adjust automatically and will need to be reset.
23. Run the application to see how the ComboBoxes
are populated.
Pages:
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162