Sound

package {
	import flash.display.Sprite;
	import flash.net.URLRequest;
	import flash.media.Sound;
	import flash.media.SoundChannel;
	import flash.media.SoundTransform;

	public class SoundTransform_constructorExample extends Sprite {
		public function SoundTransform_constructorExample() {
			var url:String="mySound.mp3";
			var mySound:Sound = new Sound();
			var channel:SoundChannel;
			var transform:SoundTransform=new SoundTransform(0.5,1.0);
			//设置音量为50%,从右声道播放

			mySound.load(new URLRequest(url));
			channel=mySound.play();
			channel.soundTransform=transform;
		}
	}
}

sound.load(stream:URLRequest, context:SoundLoaderContext = null):void;
sound.play(startTime:Number = 0, loops:int = 0, sndTransform:SoundTransform = null):SoundChannel; 生成一个新的 SoundChannel 对象来回放该声音。

 

SoundChannel 类控制应用程序中的声音,SoundChannel 类包含 stop() 方法、用于监控声道幅度(音量)的属性,以及用于对声道设置 SoundTransform 对象的属性。
leftPeak : Number →左声道的当前幅度(音量),范围从 0(静音)至 1(最大幅度)。
rightPeak : Number →右声道的当前幅度(音量),范围从 0(静音)至 1(最大幅度)。
position : Number →当播放声音时,position 属性指示声音文件中当前播放的位置。
soundTransform : SoundTransform →分配给该声道的 SoundTransform 对象。
stop():void →停止在该声道中播放声音。

 

SoundTransform(vol,panning)
vol:Number (default = 1) — 音量范围从 0(静音)至 1(最大音量)。 
panning:Number (default = 0) — 声音从左到右的平移,范围从 -1(左侧最大平移)至 1(右侧最大平移)。 值 0 表示没有平移(居中)。 

原文地址:https://www.cnblogs.com/leon3286/p/1754102.html