Flash CS3 Documentation |
|||
| ActionScript 2.0 Components Language Reference > Accordion component > Accordion.selectedChild | |||
Flash Player 6 (6.0.79.0).
Flash MX Professional 2004.
accordionInstance.selectedChild
Property; the selected child (of type UIObject) if one or more children exist; undefined if no children exist.
If the accordion has children, the code accordionInstance.selectedChild is equivalent to the code accordionInstance.getChildAt(accordionInstance.selectedIndex).
Setting this property to a child causes the accordion to begin the transition animation to display the specified child.
Changing the value of selectedChild also changes the value of selectedIndex.
If the accordion has children, the default value is accordionInstance.getChildAt(0). If the accordion doesn't have children, the default value is undefined.
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_str:String = my_acc.selectedChild.label;
// Perform action based on selected child
switch (selectedChild_str) {
case "Shipping Address":
trace("One was selected");
break;
case "Billing Address":
trace("Two was selected");
break;
case "Payment":
trace("Three was selected");
break;
}
};
my_acc.addEventListener("change", my_accListener);
Flash CS3