ActionScript 2.0 Components Language Reference |
|
|
|
| Tween class > Applying easing methods to components > Applying easing methods to an Accordion component | |||
This section describes how to add an Accordion component to a Flash document, add a few child slides, and change the default easing method and duration. If you decide to use this code in a project, reduce the value of the openDuration property to avoid annoying users with animations that are too slow when they open and close the Accordion component's child panes.
To apply a different easing method to the Accordion component:my_acc into the Instance Name text box.
import mx.core.View;
import mx.transitions.easing.*;
my_acc.createChild(View, "studio_view", {label:"Studio"});
my_acc.createChild(View, "dreamweaver_view", {label:"Dreamweaver"});
my_acc.createChild(View, "flash_view", {label:"Flash"});
my_acc.createChild(View, "coldfusion_view", {label:"ColdFusion"});
my_acc.createChild(View, "contribute_view", {label:"Contribute"});
my_acc.setStyle("openEasing", Bounce.easeOut);
my_acc.setStyle("openDuration", 3500);
This code imports the easing classes, so you can type Bounce.easeOut instead of referring to each of the classes with fully qualified names such as mx.transitions.easing.Bounce.easeOut. Next, the code adds five new child panes to the Accordion component (Studio, Dreamweaver, Flash, ColdFusion, and Contribute). The final two lines of code set the easing style from the default easing method to Bounce.easeOut and set the length of the animation to 3500 milliseconds (3.5 seconds).
Click each of the different header (title) bars to view the modified animations and switch between each pane.
If you want to increase the animation speed, decrease openDuration from 3500 milliseconds to a smaller number. The default duration for the animation is 250 milliseconds (one fourth of a second).
|
|
|
|