11.3. Adding Menus to a Form
Problem
You want to add menus to your form.
Solution
Use combo boxes or list boxes.
Discussion
You can choose from two types of form menus in your Flash movies:
combo boxes and list boxes. A combo box is
analogous to the standard HTML
<SELECT> tag, which is often referred to as
a pop-up
menu or
drop-down list. A combo box allows a user to select one item at a
time, and it displays only the selected item when the menu is not in
use. Additionally, if you set a combo box’s editable
property to true (using
setEditable(true)), the user can enter a value
by typing it into the text area associated with the combo box.
You can populate a
combo box
one item at a time using the
addItem( ) and addItemAt( )
methods. However, it is usually
easier to use the
setDataProvider( ) method to assign all the menu
items at once. You can pass the setDataProvider(
) method a reference to an array or any object that
inherits from the DataProvider class, such as a
RecordSet object. The combo box is automatically
populated with the data provider elements in the order they appear
within the data provider object. Here is an example:
// Create a new combo box.
_root.attachMovie("FComboBoxSymbol", "myComboBox_cb", 1);
// Place the combo box at (100,100).
myComboBox_cb._x = 100;
myComboBox_cb._y = 100;
// Create an array to use as the data provider.
menuItems = ["item a", "item b", "item c", "item d"];
// Populate the combo box.
myComboBox_cb.setDataProvider(menuItems);A list box ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access