as3ÖУ¬ÒôÁ¿µÄ¿ØÖƸıäµÄÊǵ±Ç°ÉùÒôͨµÀµÄÒôÁ¿´óС¡£ÒªÊµÏÖ´ËЧ¹û£¬ÐèÒª´´½¨Ò»¸öSoundTransform¶ÔÏó
as3ÖУ¬ÒôÁ¿µÄ¿ØÖƸıäµÄÊǵ±Ç°ÉùÒôͨµÀµÄÒôÁ¿´óС¡£ÒªÊµÏÖ´ËЧ¹û£¬ÐèÒª´´½¨Ò»¸öSoundTransform¶ÔÏó£¬È»ºóʹÓøöÔÏóµÄvolumeÊôÐÔÀ´¸Ä±äSoundTransform¶ÔÏóµÄÒôÁ¿Öµ£¬²¢×îºóÓ¦ÓÃÓëÉùÒôͨÐÅ¡£
ÏÂÃæʾÀýÏß´´½¨Ò»¸öSlider(»¬¿é)×é¼þ£¬Í¨¹ýÔÚ»¬¿é¹ìµÀµÄ¶ËµãÖ®¼äÒƶ¯»¬¿éÀ´µ÷½ÚÒôÁ¿µÄÖµ¡£È»ºóʹÓÃSoundTransform¶ÔÏóÀ´µ÷½ÚÒôÁ¿·¢Éú±ä»¯¡£Ê¹ÓÃÎĵµÀࣺ
- package com.lzxt{
- //µ¼Èë°ü
- import flash.display.Sprite;
- import flash.events.*;
- import flash.media.Sound;
- import flash.media.SoundChannel;
- import flash.media.SoundTransform
- import flash.net.URLRequest;
- import fl.controls.Slider
- //´´½¨ÎĵµÀà
- public class SoundVolue extends Sprite {
- //¶¨ÒåÊôÐÔ
- //¶¨ÒåÒª¼ÓÔصÄÎļþ·¾¶£¬×¢Ò⣬´Ë·¾¶ÒªÏà¶ÔÓÚSWFÎļþµÄĿ¼
- private var url:String="nobody.mp3";
- //´´½¨SoundÀàʵÀý
- private var mysound:Sound=new Sound;
- //¶¨Ò廬¿éʵÀýÃû³Æ
- private var slider:Slider
- //¶¨ÒåÉùÒôͨµÀÃû³Æ
- private var song:SoundChannel
- //¹¹Ô캯Êý
- public function SoundVolue() {
- //´´½¨URLÁ¬½Ó
- var request:URLRequest=new URLRequest(url);
- //×¢²á¼ÓÔØÍê³Éʼþ
- mysound.addEventListener(Event.COMPLETE,completeHandler);
- //¼ÓÔØÎļþ
- mysound.load(request);
- //´´½¨»¬¿é¶ÔÏóʵÀý
- slider=new Slider()
- //Òƶ¯»¬¿éλÖÃ
- slider.move(50,100)
- //CuPlayer.comÉèÖû¬¿é³õʼֵ
- slider.value=0.5;
- //ÔÚ»¬¿é¶ÔÏóÉÌ×¢²á¸Ä±äʼþ
- slider.addEventListener(Event.CHANGE,changeVolue)
- //CuPlayer.com¼ÓÈëÎę̀
- addChild(slider)
- }
- //´´½¨×ª»»ÉùÒôʼþ´¦Àíº¯Êý
- private function changeVolue(evt:Event):void{
- //´´½¨×ª»»¶ÔÏó
- var trans:SoundTransform=new SoundTransform()
- //CuPlayer.com»ñÈ¡ÉùÒôµÄÖµ£¬²¢¼ÓÈëת»»¶ÔÏó
- trans.volume=evt.target.value
- //CuPlayer.comʵÏÖת»»
- song.soundTransform=trans
- }
- //´´½¨¼ÓÔØÍê³ÉʼþÕìÌýº¯Êý
- private function completeHandler(event:Event):void {
- //CuPlayer.com¼ÓÔØÍê³É£¬¿ªÊ¼²¥·Å
- song=mysound.play();
- }
- }
- }