Тема: Как сделать ползунок громкости на actionscript 3 для плеера на flash?
В общем пироги такие. Вот сайт на котором стоит плеер cherryfm.ru . Проблема в том что незнаем как сделать ползунок. Максимум на сколько возможно это 5. Код вот:
import flash.display.Graphics;
var p_stat:int=0;
var v_stat:int=0;
var req:URLRequest = new URLRequest("http://85.10.237.228:8020/CherryFM");
var context:SoundLoaderContext = new SoundLoaderContext(2500, false);
var potok:Sound = new Sound();
var chanal:SoundChannel = new SoundChannel();
var soud_vol:SoundTransform = new SoundTransform();
var analo:Shape = new Shape();
var graf:Shape = new Shape();
var bytes:ByteArray = new ByteArray();
var n1:Array = new Array(256);
var i:int = 0;
var n:int = 0;
const xn:int = 90;
const yn:int = 40;
const razm:int = 90;
const visot:int = 25;
const cvet:int = 0x999999;
play_button.addEventListener(MouseEvent.CLICK, play_hover);
vol_button.addEventListener(MouseEvent.CLICK, vol_hover);
v_stat=3;
vol_ur(v_stat);
vol_button.gotoAndStop(v_stat);
this.addChildAt(analo,numChildren - 1);
this.addChildAt(graf,numChildren - 1);
function play_hover(event:MouseEvent):void
{
if (p_stat==0) {
p_stat=1;
play_button.gotoAndStop(2);
potok.load(req,context);
chanal=potok.play();
vol_ur(v_stat);
addEventListener(Event.ENTER_FRAME, ana);
}
else {
p_stat=0;
play_button.gotoAndStop(1);
chanal.stop();
potok.close();
var false_potok:Sound = new Sound();
potok = false_potok;
}
}
function vol_hover(event:MouseEvent):void
{
v_stat=Math.ceil(event.localX/5);
vol_button.gotoAndStop(v_stat);
vol_ur(v_stat);
}
function vol_ur(v_stat)
{
soud_vol.volume = v_stat*1/5;
chanal.soundTransform = soud_vol;
}
function ana(event:Event):void
{
analo.graphics.clear();
SoundMixer.computeSpectrum(bytes, true, 0);
analo.graphics.lineStyle(0, cvet);
analo.graphics.beginFill(cvet);
analo.graphics.moveTo(xn, yn);
analo.graphics.endFill();
for (i = 0; i < 256; i++)
{
n1[i] = bytes.readFloat();
}
for (i = 0; i < 128; i++)
{
//n=n1[i]*visot;
n=((n1[i]+n1[i+128])/2)*visot;
analo.graphics.moveTo(xn+(i*razm/128), yn);
analo.graphics.lineTo(xn+(i*razm/128), yn-n);
}
analo.graphics.endFill();
}
Нам будет ну очень приятно)
ICQ 609-930-321