User Guide
Applying easing methods to components 1317
3. Insert a new layer and rename it actions.
Make sure the actions layer is above Layer 1.
4. Add the following ActionScript to Frame 1 of the actions layer:
import mx.transitions.easing.*;
this.createClassObject(mx.controls.ComboBox, "my_cb", 20);
var product_array:Array = new Array("Studio", "Dreamweaver", "Flash",
"ColdFusion", "Contribute", "Breeze", "Director", "Flex");
my_cb.dataProvider = product_array;
my_cb.move(10, 10);
my_cb.setSize(140, 22);
my_cb.setStyle("openDuration", 2000);
my_cb.setStyle("openEasing", Elastic.easeOut);
After you import each of the easing methods, which occurs in the first line of code, the
createClassObject() method creates an instance of the ComboBox component. The
keyword
this in the second line of code refers to the main of the SWF file. This line of
code puts the component on the Stage at runtime and gives it the instance name
my_cb.
Next, you create an array named
product_array that contains a list of Macromedia
software. You use this array in the following line of code to set the
dataProvider property
to the array of product names. Then you use the
setSize() method to resize the
component instance, set
openDuration to 2000 milliseconds (2 seconds), and change the
easing method to
Elastic.easeOut.
5. Save the current document, and select Control > Test Movie to view the document in the
test environment.
6. Click the ComboBox component on the Stage to use the specified easing class to animate
your drop-down list of product names.
Animating the DataGrid component
Flash 8 also lets you tweak the animations you use when you select items in a component
(such as the DataGrid, Tree, ComboBox, or List components). Although the animations are
subtle, in some cases you want to control small details or increase the speed of the animation.
NOTE
As with earlier examples, you import the easing classes, which let you use the
shortened version of the class name instead of using the fully qualified class name of
mx.transitions.easing.Elastic.easeOut.
NOTE
Use an easing method such as Elastic or Bounce for your ComboBox or Accordion
components with care. Some users might find it distracting if your options take a
long time to stop moving before they can read and select from the menu. Test your
individual applications and settings, and decide whether the easing methods
enhance or detract from your Flash document.