User Guide
54 Accordion component (Flash Professional only)
Example
Start with an Accordion instance on the Stage named my_acc. Add a symbol to the library
with the Linkage Identifier
payIcon to be the icon for the child header. The following code
creates a child named
billing (with the label “Payment”) that is an instance of the
View class:
var child_obj:Object = my_acc.createChild(mx.core.View, "billing", {label:
"Payment", icon: "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.createChild(View, "billing", {label:
"Payment", icon: "payIcon"});
Or, add a movie clip symbol to the library with the Linkage Identifier PaymentForm to be the
Accordion child, and the following code creates an instance of
PaymentForm named billing
as the child of
my_acc (this approach is useful for dynamic content where you load the
dynamic content into a movie clip symbol, and then make that symbol a child of the
Accordion instance):
var child_obj:Object = my_acc.createChild("PaymentForm", "billing", {label:
"Payment", icon: "payIcon"});
For a more complex example, keep the Accordion instance my_acc on the Stage. Then 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). Paste the following code in the first frame of the main timeline (replacing any code
from the previous examples). 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.createChild(View, "billing",
{label:"Payment", icon: "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.