Accordion.numChildren

Availability

Flash Player 6 (6.0.79.0).

Edition

Flash MX Professional 2004.

Usage

accordionInstance.numChildren

Description

Property (inherited from View); indicates the number of children (of type UIObject) in an Accordion instance. Headers are not counted as children.

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 code my_acc.numChild - 1 always refers to the last child added to an accordion. For example, if there were seven children in an accordion, the last child would have the index 6. The numChildren property is not zero-based, so the value of my_acc.numChildren would be 7. The result of 7 - 1 is 6, which is the index number of the last child.

Example

The following code uses numChildren to get a reference to the last child of my_acc and changes the label to "Last Child":

import mx.core.View;

// Create child panels with instances of the View class.
my_acc.createSegment(View, "myMainItem1", "Menu Item 1");
my_acc.createSegment(View, "myMainItem2", "Menu Item 2");
my_acc.createSegment(View, "myMainItem3", "Menu Item 3");

// Get reference for last child object.
var lastChild_obj:Object = my_acc.getChildAt(my_acc.numChildren - 1);
// Change label of object.
lastChild_obj.label = "Last Child";

Flash CS3