Music overlapping in Flash Actionscript 3 -


i'm new as3,i'm building full flash website tried include background music play,pause , stop button(the play , pause same button). problem music player play automatically when page load , when click home button of website music plays again , overlap music played first, should do..thanks in advance

stop();  function gohome (e:mouseevent):void{ gotoandstop("home"); } home_btn.addeventlistener(mouseevent.click, gohome);  function goabout (e:mouseevent):void{ gotoandstop("company"); } company_btn.addeventlistener(mouseevent.click, goabout);  function gotestimony (e:mouseevent):void{ gotoandstop("testimony"); } news_btn.addeventlistener(mouseevent.click, gotestimony);  function goproduct (e:mouseevent):void{ gotoandstop("product"); } product_btn.addeventlistener(mouseevent.click, goproduct);  function gocontact (e:mouseevent):void{ gotoandstop("contact"); } contacts_btn.addeventlistener(mouseevent.click, gocontact);  //imports necessary events import flash.events.event import flash.events.mouseevent;  var isplaying:boolean = new boolean(); var pauseposition:number = new number();  //create instance of sound class var soundclip:sound = new sound(); //create new soundchannel object var sndchannel:soundchannel = new soundchannel();  //load sound using urlrequest soundclip.load(new urlrequest("thousandyears.mp3"));  //create event listener wll update once sound has finished loading soundclip.addeventlistener(event.complete, oncomplete, false, 0, true);  controller.addeventlistener(mouseevent.mouse_down, btnpresscontroller, false, 0, true); stop_btn.addeventlistener(mouseevent.mouse_down, btnpressstop, false, 0, true);  function oncomplete(evt:event):void {     //play loaded sound     sndchannel = soundclip.play();     isplaying = true; }  function btnpresscontroller(evt:mouseevent):void {     switch(isplaying)     {         case true:             controller.gotoandstop(2);             pauseposition = sndchannel.position;              sndchannel.stop();             isplaying = false;         break;         case false:             controller.gotoandstop(1);             sndchannel = soundclip.play(pauseposition);             isplaying = true;         break;     } }  function btnpressstop(evt:mouseevent):void {     pauseposition = 0;     sndchannel.stop();     controller.gotoandstop(2);     isplaying = false; } 

is code in frame 1? frame 1 labelled 'home'?

if add new frame @ beginning of timeline (new frame 1) , move code it. way, code still in frame 1, frame 'home' frame 2, , on.

you need update code:

replace stop() gotoandstop('home');


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -