¡¤Äúµ±Ç°µÄλÖãºÊ×Ò³ > ¼¼Êõ½Ì³Ì > AS2ÓëAS3¼¼Êõ >

[AS3]AS3ÖÐÊÓƵ²¥·ÅÆ÷ÒôÁ¿´¦Àí·½·¨¸½Ô´´úÂëʵÀý

ʱ¼ä:2015-05-17 11:49¿á²¥
as3ÖУ¬ÒôÁ¿µÄ¿ØÖƸıäµÄÊǵ±Ç°ÉùÒôͨµÀµÄÒôÁ¿´óС¡£ÒªÊµÏÖ´ËЧ¹û£¬ÐèÒª´´½¨Ò»¸öSoundTransform¶ÔÏó

as3ÖУ¬ÒôÁ¿µÄ¿ØÖƸıäµÄÊǵ±Ç°ÉùÒôͨµÀµÄÒôÁ¿´óС¡£ÒªÊµÏÖ´ËЧ¹û£¬ÐèÒª´´½¨Ò»¸öSoundTransform¶ÔÏó£¬È»ºóʹÓøöÔÏóµÄvolumeÊôÐÔÀ´¸Ä±äSoundTransform¶ÔÏóµÄÒôÁ¿Öµ£¬²¢×îºóÓ¦ÓÃÓëÉùÒôͨÐÅ¡£

ÏÂÃæʾÀýÏß´´½¨Ò»¸öSlider(»¬¿é)×é¼þ£¬Í¨¹ýÔÚ»¬¿é¹ìµÀµÄ¶ËµãÖ®¼äÒƶ¯»¬¿éÀ´µ÷½ÚÒôÁ¿µÄÖµ¡£È»ºóʹÓÃSoundTransform¶ÔÏóÀ´µ÷½ÚÒôÁ¿·¢Éú±ä»¯¡£Ê¹ÓÃÎĵµÀࣺ

  1. package com.lzxt{ 
  2.     //µ¼Èë°ü 
  3.     import flash.display.Sprite; 
  4.     import flash.events.*; 
  5.     import flash.media.Sound; 
  6.     import flash.media.SoundChannel; 
  7.     import flash.media.SoundTransform 
  8.     import flash.net.URLRequest; 
  9.     import fl.controls.Slider 
  10.     //´´½¨ÎĵµÀà 
  11.     public class SoundVolue extends Sprite { 
  12.         //¶¨ÒåÊôÐÔ 
  13.         //¶¨ÒåÒª¼ÓÔصÄÎļþ·¾¶£¬×¢Ò⣬´Ë·¾¶ÒªÏà¶ÔÓÚSWFÎļþµÄĿ¼ 
  14.         private var url:String="nobody.mp3"
  15.         //´´½¨SoundÀàʵÀý 
  16.         private var mysound:Sound=new Sound; 
  17.         //¶¨Ò廬¿éʵÀýÃû³Æ 
  18.         private var slider:Slider 
  19.         //¶¨ÒåÉùÒôͨµÀÃû³Æ 
  20.         private var song:SoundChannel 
  21.         //¹¹Ô캯Êý 
  22.         public function SoundVolue() { 
  23.             //´´½¨URLÁ¬½Ó 
  24.             var request:URLRequest=new URLRequest(url); 
  25.             //×¢²á¼ÓÔØÍê³Éʼþ 
  26.             mysound.addEventListener(Event.COMPLETE,completeHandler); 
  27.             //¼ÓÔØÎļþ 
  28.             mysound.load(request); 
  29.             //´´½¨»¬¿é¶ÔÏóʵÀý 
  30.             slider=new Slider() 
  31.             //Òƶ¯»¬¿éλÖà
  32.             slider.move(50,100) 
  33.             //CuPlayer.comÉèÖû¬¿é³õʼֵ 
  34.             slider.value=0.5; 
  35.             //ÔÚ»¬¿é¶ÔÏóÉÌ×¢²á¸Ä±äʼþ 
  36.             slider.addEventListener(Event.CHANGE,changeVolue) 
  37.             //CuPlayer.com¼ÓÈëÎę̀ 
  38.             addChild(slider) 
  39.         } 
  40.         //´´½¨×ª»»ÉùÒôʼþ´¦Àíº¯Êý 
  41.         private function changeVolue(evt:Event):void{ 
  42.             //´´½¨×ª»»¶ÔÏó 
  43.             var trans:SoundTransform=new SoundTransform() 
  44.             //CuPlayer.com»ñÈ¡ÉùÒôµÄÖµ£¬²¢¼ÓÈëת»»¶ÔÏó 
  45.             trans.volume=evt.target.value 
  46.             //CuPlayer.comʵÏÖת»» 
  47.             song.soundTransform=trans 
  48.         } 
  49.         //´´½¨¼ÓÔØÍê³ÉʼþÕìÌýº¯Êý 
  50.         private function completeHandler(event:Event):void { 
  51.             //CuPlayer.com¼ÓÔØÍê³É£¬¿ªÊ¼²¥·Å 
  52.             song=mysound.play(); 
  53.         } 
  54.     } 

 

ÈÈÃÅÎÄÕÂÍƼö

ÇëÉÔºò...

±£ÀûÍþÊÓÔÆƽ̨-ÇáËÉʵÏֵ㲥ֱ²¥ÊÓƵӦÓÃ

¿á²¥ÔÆÊý¾Ýͳ¼Æ·ÖÎö¿çƽ̨²¥·ÅÆ÷