Developer Network Home  Help 

YDN Flash Developer Center Astra Flash Components Carousel
Flash Developer Center

Astra Carousel

Carousel is a UI component used for for displaying a list of items, much like the standard List component. Additionally, it provides many useful hooks for customizing how the items are positioned and displayed.

Getting Started: Carousel for Flash CS3

Similar to other Flash components, you can create a Carousel by placing an instance on the stage or by using ActionScript to create an instance dynamically.

Initializing a Carousel on the Stage

The easiest way to create a Carousel is to drag it from the Components panel to the stage. This will immediately create a Carousel instance and add it to the display list. You may use the Properties panel to set some of its basic properties, like the position and size of the component. The Parameters panel provides ways to set things like the data provider. For more advanced functionality, you must manipulate the Carousel with ActionScript.

To see a live example, please install Adobe Flash Player version 9 or higher and ensure that JavaScript is enabled.

Download the FLA file.

Initializing a Carousel with ActionScript

To add a Carousel to your application with ActionScript, you must first include the Carousel component in your library. Drag it from the Components panel directly to the library, or drag an instance to the stage and immediately delete it (the component will stay in your library). Additionally, you must import the following classes in your class or frame script.

The class com.yahoo.astra.fl.controls.Carousel is the main required class for a Carousel control. The second import, fl.data.DataProvider, is the same data provider type that is used by the Flash CS3 List control. You should use this class to pass data to the Carousel to display.

You may also want to import another package, com.yahoo.astra.fl.controls.carouselClasses.* if you plan to customize the layout of the Carousel. This is discussed in more detail in Using Carousel.

Like any other Flash display object, you must add a Carousel to the display list by passing it to the addChild method on the intended parent. The following example instantiates a Carousel with the same properties as the first example above.

First, we create an Array of data and pass it to the Carousel with a DataProvider. Next, we specify the labelField and sourceField properties so that the Carousel knows how to interpret each item to access the label text and the image source. We position and size the Carousel with the standard move() and setSize() functions before we add it to the display list with addChild().

For additional topics, please read Using Carousel, or take a look at the Examples section for functional demonstrations. The ActionScript 3.0 Class Reference contains full details on every property, method, and style available to the Carousel component.