Soy una re-principiante en actionscript 3...estoy recien empezando y armè este player. Funciona perfecto pero al subirlo al servidor...la barra de progreso se vuelve loca! luego de un tiempo se tranquiliza y funciona bien. Un compañero me dijo que le tenia que poner un stop a la musica. Pero el solo sabe actionscript 2 y no se como hacerlo.No encuentro el error...
Tendran idea porque la barra de progreso se vuelve loca cuando veo la pagina subida en la web?
Tendran idea de como arreglar el codigo? podrian ayudarme a arreglarlo?
les dejo el codigo para que lo vean.
Les agradezco un monton de antemano...
mil gracias!!!
Saludos,
Orangejuice.-
Código ActionScript :
volume_mc.slider_mc.useHandCursor = true; var musicReq:URLRequest; var music:Sound = new Sound(); var sc:SoundChannel; var currentSound:Sound = music; var pos:Number; var songPlaying:Boolean = false; var xml:XML; var songlist:XMLList; var currentIndex:Number = 0; var loader:URLLoader = new URLLoader(); loader.addEventListener(Event.COMPLETE, whenLoaded); var imgSrc=""; var bolStop:Boolean = true mc_progress.buttonMode = true; function whenLoaded(e:Event):void { xml = new XML(e.target.data); songlist = xml.song; musicReq = new URLRequest(songlist[0].url); music.load(musicReq); sc = music.play(); txtImageSrc.text= songlist[0].image; txtName.text = songlist[0].title; txtlenght.text = songlist[0].lenght; title_txt.text = songlist[0].title; artist_txt.text = songlist[0].artist; artist_txt2.text = songlist[currentIndex].artist; sc.addEventListener(Event.SOUND_COMPLETE, nextSong); addEventListener (Event.ENTER_FRAME, calcProgress); play_btn.visible = false; mostrarImagen(0); } function mostrarImagen(index) { var contenedor = new Loader(); contenedor.load(new URLRequest("./" + songlist[index].image)); imgHolder.addChild(contenedor); contenedor.x = 0; contenedor.y= 0; } loader.load(new URLRequest("promolist-04.xml")); stop_btn.addEventListener(MouseEvent.CLICK, stopPlayback); pause_btn.addEventListener(MouseEvent.CLICK, pausePlayback); play_btn.addEventListener(MouseEvent.CLICK, startPlayback); next_btn.addEventListener(MouseEvent.CLICK, nextSong); prev_btn.addEventListener(MouseEvent.CLICK, prevSong); mc_progress.addEventListener(MouseEvent.CLICK, setNewProgress); function nextSong(e:Event):void { if (currentIndex < (songlist.length() - 1)) { currentIndex++; } else { currentIndex = 0; } trace(currentIndex); mostrarImagen(currentIndex); var nextReq:URLRequest = new URLRequest(songlist[currentIndex].url); var nextTitle:Sound = new Sound(nextReq); sc.stop(); txtImageSrc.text= songlist[currentIndex].image; txtName.text = songlist[currentIndex].title; txtlenght.text = songlist[currentIndex].lenght; title_txt.text = songlist[currentIndex].title; artist_txt.text = songlist[currentIndex].artist; artist_txt2.text = songlist[currentIndex].artist; sc = nextTitle.play(); songPlaying = true; currentSound = nextTitle; sc.addEventListener(Event.SOUND_COMPLETE, nextSong); addEventListener (Event.ENTER_FRAME, calcProgress); } function prevSong(e:Event):void { if (currentIndex > 0) { currentIndex--; } else { currentIndex = songlist.length() - 1; } mostrarImagen(currentIndex); var nextReq:URLRequest = new URLRequest(songlist[currentIndex].url); var prevTitle:Sound = new Sound(nextReq); sc.stop(); txtImageSrc.text= songlist[currentIndex].image; txtName.text = songlist[currentIndex].title; txtlenght.text = songlist[currentIndex].lenght; title_txt.text = songlist[currentIndex].title; artist_txt.text = songlist[currentIndex].artist; artist_txt2.text = songlist[currentIndex].artist; sc = prevTitle.play(); songPlaying = true; currentSound = prevTitle; sc.addEventListener(Event.SOUND_COMPLETE, nextSong); addEventListener (Event.ENTER_FRAME, calcProgress); } function stopPlayback(e:MouseEvent):void { sc.stop(); music = new Sound(); bolStop = true; pos = 0; play_btn.visible = true; pause_btn.visible = false; } function pausePlayback(e:MouseEvent):void { playSound(false); play_btn.visible = true; pause_btn.visible = false; } function startPlayback(e:MouseEvent):void { playSound(); pause_btn.visible = true; play_btn.visible = false; } function playSound(bolPlay:Boolean = true):void { if(bolPlay) { if(bolStop) { music.load(musicReq); bolStop = false; } else { pos = sc.position; } sc = music.play(pos); } else { sc.stop(); } } function setNewProgress(e:MouseEvent):void { var t:int = music.length * e.currentTarget.mouseX / 220; sc.stop(); songPlaying = true; sc = music.play(t); } function calcProgress(e:Event):void { var p:MovieClip = this.mc_progress.mcProgressFill; var w:int = Math.round( 220 * sc.position / music.length); p.width = w; } var dragging:Boolean = false; var rect:Rectangle = new Rectangle(0,0,50,0); volume_mc.slider_mc.addEventListener(MouseEvent.MOUSE_DOWN,dragIt); volume_mc.slider_mc.addEventListener(MouseEvent.MOUSE_UP,dropIt); stage.addEventListener(MouseEvent.MOUSE_UP,dropIt); function dragIt(e:Event):void { dragging = true; e.target.startDrag(false,rect); e.target.addEventListener(MouseEvent.MOUSE_MOVE, adjustVolume); } function dropIt(e:Event):void { if (dragging) { var vol:Number = volume_mc.slider_mc.x * .02; var st:SoundTransform = new SoundTransform(vol,0); sc.soundTransform = st; volume_mc.slider_mc.stopDrag(); volume_mc.slider_mc.removeEventListener(MouseEvent.MOUSE_MOVE, adjustVolume); dragging = false; } } function adjustVolume(e:Event):void { var vol:Number = volume_mc.slider_mc.x * .02; var st:SoundTransform = new SoundTransform(vol,0); sc.soundTransform = st; }