Security.loadPolicyFile("http://doskater.com/crossdomain.xml"); import flash.display.Graphics; import flash.events.TimerEvent; import flash.utils.Timer; import flash.net.URLRequest; var p_stat:int=0; var v_stat:int=0; var req:URLRequest = new URLRequest("http://109.120.144.244:8000/live"); var context:SoundLoaderContext = new SoundLoaderContext(2500, false); var potok:Sound = new Sound(); var chanal:SoundChannel = new SoundChannel(); var soud_vol:SoundTransform = new SoundTransform(); var data_html:String; var f_non_stop:Boolean = true; var f_live:Boolean = false; var ob:Object = vol_mc_3; var urlLoader:URLLoader = new URLLoader(); var timer:Timer = new Timer(2000); timer.addEventListener(TimerEvent.TIMER, onTick); play_mc.addEventListener(MouseEvent.CLICK, play_nazh); vol_mc_1.addEventListener(MouseEvent.CLICK, vol_nazh_1); vol_mc_2.addEventListener(MouseEvent.CLICK, vol_nazh_2); vol_mc_3.addEventListener(MouseEvent.CLICK, vol_nazh_3); vol_mc_4.addEventListener(MouseEvent.CLICK, vol_nazh_4); vol_mc_5.addEventListener(MouseEvent.CLICK, vol_nazh_5); v_stat=3; vol_ur(v_stat); vol_mc_3.gotoAndStop(2); function play_nazh(event:MouseEvent):void { if (p_stat==0) { play_mc.gotoAndStop(2); p_stat=1; potok.load(req,context); chanal=potok.play(); vol_ur(v_stat); timer.start(); } else { play_mc.gotoAndStop(1); p_stat=0; chanal.stop(); potok.close(); var false_potok:Sound = new Sound(); potok = false_potok; timer.stop(); curSong.txt.text = ""; listeners.text = ""; } } function onTick(event:TimerEvent):void { if(p_stat == 0) { curSong.txt.text = ""; listeners.text = ""; return; } urlLoader.load(new URLRequest("http://109.120.144.244:8000/status.xsl")); urlLoader.addEventListener(Event.COMPLETE,onComplete); } function onComplete(event:Event):void { data_html = event.target.data; curSong.txt.htmlText = antara(data_html, "<td>Current Song:</td>\n<td class=\"streamdata\">", "</td>"); listeners.text = antara(data_html, "Current Listeners:</td>\n<td class=\"streamdata\">", "</td>"); if(antara(data_html, "<td><h3>Mount Point ", "</h3></td>") == "/live") { if(f_non_stop) { f_non_stop = false; f_live = true; chanal.stop(); var false_potok1:Sound = new Sound(); potok = false_potok1; potok.load(req, context); chanal = potok.play(); vol_ur(v_stat); } } else { if(f_live) { f_live = false; f_non_stop = true; chanal.stop(); var false_potok2:Sound = new Sound(); potok = false_potok2; potok.load(req, context); chanal = potok.play(); vol_ur(v_stat); } } data_html = ""; } function antara(string:String, st:String, end:String):String { string = " " + string; var ini:Number = string.indexOf(st); if (ini == 0) return ""; ini += st.length; var len:Number = string.indexOf(end, ini) - ini; return string.substr(ini,len); } function vol_nazh_1(event:MouseEvent):void { ob.gotoAndStop(1); ob = vol_mc_1; ob.gotoAndStop(2); v_stat=1; vol_ur(v_stat); } function vol_nazh_2(event:MouseEvent):void { ob.gotoAndStop(1); ob = vol_mc_2; ob.gotoAndStop(2); v_stat=2; vol_ur(v_stat); } function vol_nazh_3(event:MouseEvent):void { ob.gotoAndStop(1); ob = vol_mc_3; ob.gotoAndStop(2); v_stat=3; vol_ur(v_stat); } function vol_nazh_4(event:MouseEvent):void { ob.gotoAndStop(1); ob = vol_mc_4; ob.gotoAndStop(2); v_stat=4; vol_ur(v_stat); } function vol_nazh_5(event:MouseEvent):void { ob.gotoAndStop(1); ob = vol_mc_5; ob.gotoAndStop(2); v_stat=5; vol_ur(v_stat); } function vol_ur(v_stat) { soud_vol.volume = v_stat*1/6; chanal.soundTransform = soud_vol; }