Table of Contents

Sound.setTransform( ) Method Flash 5

distribute the left and right channels between the left and right speakers
soundObject.setTransform(transformObject)

Arguments

transformObject

A user-defined object that specifies new channel settings as a series of reserved properties.

Description

The setTransform( ) method gives us precise control over how the channels in a sound are output to the left and right speakers. In principle, setTransform( ) is not unlike setPan( ), but it provides more detailed sound control over stereo sounds.

A stereo sound is a combination of two distinct sounds—the left channel and the right channel—which normally are sent separately to the left and right speakers. However, using setTransform( ), we can dictate how much of each channel is broadcast in each speaker. For example, we can tell Flash to play half of the left channel in the left speaker, none of the left channel in the right speaker, and all of the right channel in both speakers. Or we can tell Flash to play all of the left and right channels in the left speaker only.

To use setTransform( ), we must first create an object with a series of predefined properties. The properties express how to distribute the left and right channels of a stereo sound between the left and right speakers, as described in Table 18-19.

Table 18-19. Properties of a transformObject

Property name

Property value

Property description

ll

0 to 100

The percentage of the left channel to play in the left speaker

lr

0 to 100

The percentage of the right channel to play in the left speaker

rl

0 to 100

The percentage of the left channel to play in the right speaker

rr

0 to 100

The percentage of the right channel to play in the right speaker

Once we have created an object with the properties described in Table 18-19, we pass that object to the setTransform( ) method of our Sound object. The values of the properties on our transformObject become the new channel output percentages for the sounds controlled by soundObject.

To examine the current percentages of a particular Sound object, we use the Sound.getTransform( ) method.

Example

// Create a new Sound object
mySound = new Sound();
   
// Create a new generic object to use with setTransform( )
transformer = new Object();
   
// Set the properties of the transform object
transformer.ll = 0;      // None of left channel in left speaker
transformer.lr = 0;      // None of right channel in left speaker
transformer.rl = 0;      // None of left channel in right speaker
transformer.rr = 100;    // All of right channel in right speaker
   
// Apply the new channel distribution by passing the transform
// object to the setTransform( ) method
mySound.setTransform(transformer);

See Also

Sound.getTransform( ), Sound.setPan( ), Sound.setVolume( )


Table of Contents