User Guide

Accordion.selectedIndex 63
Description
Property; the zero-based index of the selected child in an accordion with one or more
children. For an accordion with no child views, the only valid value is
undefined.
Each accordion child is given an index number for its position. This index number is zero-
based, so the first child is 0, the second child is 1, and so on. The valid values of
selectedIndex are 0, 1, 2, ... , n - 1, where n is the number of children.
Setting this property to a child causes the accordion to begin the transition animation to
display the specified child.
Changing the value of
selectedIndex also changes the value of selectedChild.
Example
The following example detects when a child is selected and displays the child’s order in the
Output panel each time a header is selected:
// Create new Listener object.
var my_accListener:Object = new Object();
my_accListener.change = function() {
trace("Changed to different view");
// Assign label of child panel to variable.
var selectedChild_num:Number = my_acc.selectedIndex;
// Perform action based on selected child.
switch (selectedChild_num) {
case 0:
trace("One was selected");
break;
case 1:
trace("Two was selected");
break;
case 2:
trace("Three was selected");
break;
}
};
my_acc.addEventListener("change", my_accListener);
See also
Accordion.numChildren, Accordion.selectedChild