Accordion.createSegment()

Availability

Flash Player 6 (6.0.79.0).

Edition

Flash MX Professional 2004.

Usage

accordionInstance.createSegment(classOrSymbolName, instanceName[, label[, icon]])

Parameters

classOrSymbolName Either a reference to the constructor function for the class of the UIObject to be instantiated, or the linkage name of the symbol to be instantiated. The class must be UIObject or a subclass of UIObject, but most often it is View or a subclass of View.

instanceName The instance name of the new instance.

label A string that specifies the text label that the new child instance uses on its header. This parameter is optional.

icon A string reference to the linkage identifier of the library symbol that the child uses for the icon on its header. This parameter is optional.

Returns

A reference to the newly created UIObject instance.

Description

Method; creates a child for the accordion. The newly created child is added to the end of the list of children owned by the accordion. Use this method to place views inside the accordion. The created child is an instance of the class or movie clip symbol specified in the classOrSymbolName parameter. You can use the label and icon parameters to specify a text label and an icon for the associated accordion header for each child.

The createSegment() method differs from the createChild() method in that label and icon are passed directly as parameters, not as properties of an initalProperties parameter.

When each child is created, it is assigned an index number in the order of creation, and the numChildren property is increased by 1.

Example

Start with an Accordion instance on the Stage named my_acc. Add a movie clip symbol to the library with the Linkage Identifier PaymentForm to be the Accordion child. Then, add a symbol to the library with Linkage Identifier payIcon to be the icon for the child header. The following example creates an instance of the PaymentForm movie clip symbol named billing as the last child of my_acc with header label "Payment" and the icon in the library:

var child_obj:Object = my_acc.createSegment("PaymentForm", "billing", "Payment", "payIcon");

The following code creates a child that is an instance of the View class:

var child_obj:Object = my_acc.createSegment(mx.core.View, "billing", "Payment", "payIcon");

The following code also creates a child that is an instance of the View class, but it uses import to reference the constructor for the View class:

import mx.core.View;
var child_obj:Object = my_acc.createSegment(View, "billing", "Payment", "payIcon");

Drag a Label component and a TextInput component from the Components panel to the current document's library (so that you have both a TextInput symbol and a Label symbol in the library).The following code creates a child that is an instance of the View class named billing, and also adds children to billing to provide labels and text input fields for a form:

import mx.core.View;
import mx.controls.Label;
import mx.controls.TextInput;
var child_obj:Object = my_acc.createSegment(View, "billing", "Payment", "payIcon");
// Create labels as children of the view instance.
var cardType_label:Object = child_obj.createChild(Label, "CardType_label", {_x:10, _y:50});
var cardNumber_label:Object = child_obj.createChild(Label, "CardNumber_label", {_x:10, _y:100});
// Create text inputs as children of the view instance.
var cardTypeInput_ti:Object = child_obj.createChild(TextInput, "CardType_ti", {_x:150, _y:50});
var cardNumberInput_ti:Object = child_obj.createChild(TextInput, "CardNumber_ti", {_x:150, _y:100});
// Fill in labels.
cardType_label.text = "Card Type";
cardNumber_label.text = "Card Number";

Flash CS3