i'm creating simple music player. play 1 song. want create simple seekbar. 1 graphic work seek component - can moved right , left (between 2 points on x axis: starting point graphic @ moment, , ending point when song ends) , correspond channel.position of song. wrap up: want ask kind soul give me hint of code should use make graphic move on axis x in way corresponds channel.position of song.
this code far:
movieclip_1.stop(); var itsstoped:boolean; var youpausedit:boolean; var counter:timer = new timer(100); var chan:soundchannel; var song:sound = new sound(); song.load(new urlrequest("wmc2.mp3")); song.addeventlistener(event.complete, soundloaded); function soundloaded(event:event) { trace("song has been loaded."); } counter.addeventlistener(timerevent.timer,countcounter); itsstoped = true; youpausedit = false; button_2.addeventlistener(mouseevent.click, presser); function presser(event:mouseevent):void { if(itsstoped == true && youpausedit == true) { movieclip_1.gotoandplay(1); chan = song.play(chan.position); itsstoped = false; } else if(itsstoped == false) { movieclip_1.gotoandstop(1); chan.stop(); itsstoped = true; youpausedit = true; } else if(itsstoped == true && youpausedit == false) { movieclip_1.gotoandplay(1); chan = song.play(); counter.start(); itsstoped = false; } } function countcounter(e:timerevent):void { trace(chan.position/song.length); var percentage:uint = 100 * (chan.position / song.length); trace(percentage); if(percentage == 100) { movieclip_1.gotoandstop(1); itsstoped = true; youpausedit = false; } }
ignore movieclip_1 it's animation runs when music plays.
something that:
addeventlistener(event.enter_frame,oneframe); function oneframe(e:event):void { graphic.x = graphicstartx + music.position/music.length*(graphicendx-graphicstartx); }
Comments
Post a Comment