Не могу установить уровень громкости в приложении по прослушиванию радиостанций.
Пишет ошибку:
Код:
Монтажный кадр 1, слой "AS", кадр 1, строка 6 1061: Обращение к возможно неопределенному методу setVolume через ссылку статического типа flash.media:Sound.
Сам код:
Код AS3:
var snd:Sound = new Sound();
var channel:SoundChannel = new SoundChannel();
var req:URLRequest = new URLRequest();
var context:SoundLoaderContext = new SoundLoaderContext(3000,false);
var play_url:String;
snd.setVolume(50);
/*-------------------Слушатели-------------------*/
radio1.addEventListener(MouseEvent.CLICK, play1);
radio2.addEventListener(MouseEvent.CLICK, play2);
radio3.addEventListener(MouseEvent.CLICK, play3);
radio4.addEventListener(MouseEvent.CLICK, play4);
radioStop.addEventListener(MouseEvent.CLICK, radioSt);
radioPlay.addEventListener(MouseEvent.CLICK, radioPl);
/*-------------------Радиостанция 01-------------------*/
function play1(e:MouseEvent):void
{
play_url = 'http://stream.epicradio.co.uk:8000/live';
playSound(play_url);
name_txt.text="Epic"
radioPlay.visible=false;
radioStop.visible=true;
}
/*-------------------Функция воспроизведения-------------------*/
function playSound(station:String)
{
channel.stop();
req.url = station;
snd = new Sound();
snd.load(req, context);
channel = snd.play();
}
/*-------------------Кнопка "Стоп"-------------------*/
function radioSt(e:MouseEvent):void
{
channel.stop();
radioPlay.visible=true;
radioStop.visible=false;
}
/*-------------------Кнопка "Плей"-------------------*/
function radioPl(e:MouseEvent):void
{
playSound(play_url); // адрес будет взят из глобальной переменной play_url
radioPlay.visible=false;
radioStop.visible=true;
}
Кто-нибудь может сказать, что я делаю не так?