Saturday, October 2, 2010

Using the ComboBox component: Part 1

Today we will learn how to use the ComboBox component.

First of all, what is a combo-box? It is a rectangular component with a text field and an arrow, which allows the user to select one option out of multiple given ones, or enter his own (if the ComboBox is set to be editable by the programmer).

ComboBox uses dataProvider to store the information about possible options. Each object in the dataProvider array has 2 properties - label and value. Label is the text that is displayed in the drop-down list of ComboBox, value is the value that can be later used with Actionscript.

If you are using Adobe Flash, you can edit the dataProvider (and other properties too) using the component inspector:




As you can see, this component has 7 properties: dataProvider, editable, enabled, prompt, restrict, rowCount, visible.

We already know what dataProvider is, as well as the enabled and visible properties from previous tutorials.

Editable property is a boolean, which determines whether the user is allowed to write his own option in the ComboBox.

Prompt is the piece of text that appears before any option is selected.

Restrict is the property that is responsible for what is the user allowed to write (if the editable boolean is true). For example, if restrict is set to "abc", the user will be able to use the "a", "b" and "c" symbols in his written text. You can also set 1-9, A-Z, etc.

The rowCount property shows how many rows are displayed in the drop-down list.

Here is an example of what a ComboBox can look like:


Now that we know what a ComboBox is, we can start working with it using AS3 in the next tutorial.

Thanks for reading!

Related:

Using ComboBox component: Part 2

No comments:

Post a Comment