Developer Network Home  Help 

YDN Flash Developer Center Astra Flash Components AudioPlayback
Flash Developer Center

ASTRA AudioPlayback

AudioPlayback is a UI component that creates a set of controls for audio playback.

Getting Started: AudioPlayback for Flash CS3

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

Initializing a AudioPlayback component on the Stage

The easiest way to create an AudioPlayback component is to drag it from the Components panel to the stage. This will immediately create an AudioPlayback instance and add it to the display list. You will need to use actionscript to set its width and load the media file.

Note: In order for the AudioPlayback component to display the artist and title of your mp3, your mp3 file will need to either be in hosted in the same domain as the AudioPlayback component's SWF or be hosted in a domain that contains a crossdomain.xml file that allows the domain of the AudioPlayback component's SWF.

Screen capture of AudioPlayback

To see a live example, please install Adobe Flash Player version 9 or higher.

Download the FLA file.

Let's create an application that contains an AudioPlayback component and a form field to allow the user to type in a url for the audio file. First, we will drag the following components to the stage.

Next, we'll use actionscript to set the width of the audio player and attach a function that will load audio when the user clicks the button.

Initializing an AudioPlayback component with ActionScript

To include an AudioPlayback component in your application with ActionScript, you must first add the AudioPlayback component to your library. You can do so by dragging it from the Components panel directly to the library, or by dragging an instance to the stage, and immediately removing it (it will stay in your library). Additionally, you need to import the following class for use in your class or frame script.

Instantiate each component and add the function to load the audio.

Download the FLA file.

For additional topics, please read Using AudioPlayback, 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 AudioPlayback component.