Name

Sound.setPan( ) Method — set the balance of a sound’s left and right channels

Availability

Flash 5

Synopsis

soundObject.setPan(pan)

Arguments

pan

A number between -100 (left) and 100 (right) indicating the distribution between the left and right speakers for sounds controlled by soundObject. If the pan supplied is greater than 100, the actual value assigned is 200 - pan. If the pan supplied is less than -100, the actual value assigned is -200 - pan.

Description

The setPan( ) method dictates the balance of the right and left channels of the sounds controlled by soundObject. By adjusting the pan over time, we can cause a sound to move from one speaker to the other (known as panning).

To play the sounds controlled by soundObject in the left speaker only, use a pan of -100. To play the sounds controlled by soundObject in the right speaker only, use a pan of 100. To balance the two channels evenly, use a pan of 0.

Note that setPan( ) affects all the sounds controlled by soundObject. If soundObject is a global sound, setPan( ) affects all the sounds in a movie. If soundObject is tied to a clip or a main timeline, setPan( ) affects all the sounds in that clip or timeline and all the clips it contains.

The effects of setPan( ) can be changed only by another call to setPan( ). A setPan( ) assignment affects all future sounds controlled by soundObject, even if soundObject is deleted.

Example

The following clip event handlers cause sounds in a movie clip to endlessly pan between the left and ...

Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.