| Package | flash.media |
| Class | public final class SoundTransform |
| Inheritance | SoundTransform Object |
soundTransform property,
the value of which is a SoundTransform object: Microphone, NetStream, SimpleButton,
SoundChannel, SoundMixer, and Sprite.
| Property | Defined by | ||
|---|---|---|---|
![]() | constructor : Object
A reference to the class object or constructor function for a given object instance.
| Object | |
| leftToLeft : Number
A value, from 0 (none) to 1 (all), specifying how much of the left input is played in the
left speaker.
| SoundTransform | ||
| leftToRight : Number
A value, from 0 (none) to 1 (all), specifying how much of the left input is played in the
right speaker.
| SoundTransform | ||
| pan : Number
The left-to-right panning of the sound, ranging from -1 (full pan left)
to 1 (full pan right).
| SoundTransform | ||
![]() | prototype : Object
[static]
A reference to the prototype object of a class or function object.
| Object | |
| rightToLeft : Number
A value, from 0 (none) to 1 (all), specifying how much of the right input is played in the
left speaker.
| SoundTransform | ||
| rightToRight : Number
A value, from 0 (none) to 1 (all), specifying how much of the right input is played in the
right speaker.
| SoundTransform | ||
| volume : Number
The volume, ranging from 0 (silent) to 1 (full volume).
| SoundTransform | ||
| Method | Defined by | ||
|---|---|---|---|
|
Creates a SoundTransform object.
| SoundTransform | ||
![]() |
Indicates whether an object has a specified property defined.
| Object | |
![]() |
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter.
| Object | |
![]() |
Indicates whether the specified property exists and is enumerable.
| Object | |
![]() |
Sets the availability of a dynamic property for loop operations.
| Object | |
![]() |
Returns the string representation of the specified object.
| Object | |
![]() |
Returns the primitive value of the specified object.
| Object | |
| leftToLeft | property |
leftToLeft:Number [read-write]A value, from 0 (none) to 1 (all), specifying how much of the left input is played in the left speaker.
Implementation public function get leftToLeft():Number
public function set leftToLeft(value:Number):void
| leftToRight | property |
leftToRight:Number [read-write]A value, from 0 (none) to 1 (all), specifying how much of the left input is played in the right speaker.
Implementation public function get leftToRight():Number
public function set leftToRight(value:Number):void
| pan | property |
pan:Number [read-write]The left-to-right panning of the sound, ranging from -1 (full pan left) to 1 (full pan right). A value of 0 represents no panning (balanced center between right and left).
Implementation public function get pan():Number
public function set pan(value:Number):void
| rightToLeft | property |
rightToLeft:Number [read-write]A value, from 0 (none) to 1 (all), specifying how much of the right input is played in the left speaker.
Implementation public function get rightToLeft():Number
public function set rightToLeft(value:Number):void
| rightToRight | property |
rightToRight:Number [read-write]A value, from 0 (none) to 1 (all), specifying how much of the right input is played in the right speaker.
Implementation public function get rightToRight():Number
public function set rightToRight(value:Number):void
| volume | property |
volume:Number [read-write]The volume, ranging from 0 (silent) to 1 (full volume).
Implementation public function get volume():Number
public function set volume(value:Number):void
| SoundTransform | () | constructor |
public function SoundTransform(vol:Number = 1, panning:Number = 0)Creates a SoundTransform object.
Parametersvol:Number (default = 1) — The volume, ranging from 0 (silent) to 1 (full volume).
|
|
panning:Number (default = 0) — The left-to-right panning of the sound, ranging from -1 (full pan left)
to 1 (full pan right). A value of 0 represents no panning (center).
|
package {
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.*;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
import flash.net.URLRequest;
import flash.utils.Timer;
public class SoundTransformExample extends Sprite {
private var url:String = "MySound.mp3";
private var soundFactory:Sound;
private var channel:SoundChannel;
private var positionTimer:Timer;
public function SoundTransformExample() {
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
var request:URLRequest = new URLRequest(url);
soundFactory = new Sound();
soundFactory.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
soundFactory.load(request);
channel = soundFactory.play();
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
}
private function ioErrorHandler(event:Event):void {
trace("ioErrorHandler: " + event);
}
private function setPan(pan:Number):void {
trace("setPan: " + pan.toFixed(2));
var transform:SoundTransform = channel.soundTransform;
transform.pan = pan;
channel.soundTransform = transform;
}
private function setVolume(volume:Number):void {
trace("setVolume: " + volume.toFixed(2));
var transform:SoundTransform = channel.soundTransform;
transform.volume = volume;
channel.soundTransform = transform;
}
private function mouseMoveHandler(event:MouseEvent):void {
var halfStage:uint = Math.floor(stage.stageWidth / 2);
var xPos:uint = event.stageX;
var yPos:uint = event.stageY;
var value:Number;
var pan:Number;
if (xPos > halfStage) {
value = xPos / halfStage;
pan = value - 1;
} else if (xPos < halfStage) {
value = (xPos - halfStage) / halfStage;
pan = value;
} else {
pan = 0;
}
var volume:Number = 1 - (yPos / stage.stageHeight);
setVolume(volume);
setPan(pan);
}
}
}
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flex/2/langref/flash/media/SoundTransform.html