# Sound Autoplay Overlapping

**URL:** <https://forum.kirupa.com/t/sound-autoplay-overlapping/305180>\
**Category:** flash\
**Created:** [February 20, 2010, 2:24pm UTC](https://forum.kirupa.com/t/sound-autoplay-overlapping/305180 "2010-02-20T14:24:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![izzo101](https://avatars.discourse-cdn.com/v4/letter/i/c6cbf5/32.png) [@izzo101](https://forum.kirupa.com/u/izzo101)\
**Post date:** [February 20, 2010, 2:24pm UTC](https://forum.kirupa.com/t/sound-autoplay-overlapping/305180/1 "2010-02-20T14:24:21Z")

</div>

[FONT=arial][SIZE=3]I have this script (below) and I’m using the next/prev button script to navigate back and forth. When I navigate back to the first page which has the actionscript code to load the music, it begins to load the song again and they overlap. How do I stop loading when song is already on?[/SIZE][/FONT]

[FONT=arial][SIZE=3]var audio:Sound = new Sound();[/SIZE][/FONT]  
[SIZE=3][FONT=arial]var req:URLRequest = new URLRequest(“MenuBackground.mp3”);[/FONT][/SIZE]  
[SIZE=3][FONT=arial]audio.load(req);[/FONT][/SIZE]  
[FONT=arial][SIZE=3]var channel:SoundChannel = audio.play(0,1000);[/SIZE][/FONT]  
[SIZE=3][FONT=arial]var xForm:SoundTransform = new SoundTransform();[/FONT][/SIZE]  
[FONT=arial][SIZE=3]musicOn\_btn.addEventListener(MouseEvent.CLICK, playSound);[/SIZE][/FONT]  
[SIZE=3][FONT=arial]function playSound (evt:MouseEvent):void{[/FONT][/SIZE]  
[SIZE=3][FONT=arial]xForm.volume = 1;[/FONT][/SIZE]  
[SIZE=3][FONT=arial]channel.soundTransform = xForm[/FONT][/SIZE]  
[SIZE=3][FONT=arial]};[/FONT][/SIZE]  
[FONT=arial][SIZE=3]musicOff\_btn.addEventListener(MouseEvent.CLICK, muteSound);[/SIZE][/FONT]  
[SIZE=3][FONT=arial]function muteSound (evt:MouseEvent):void{[/FONT][/SIZE]  
[SIZE=3][FONT=arial]xForm.volume = 0;[/FONT][/SIZE]  
[SIZE=3][FONT=arial]channel.soundTransform = xForm[/FONT][/SIZE]  
[SIZE=3][FONT=arial]};[/FONT][/SIZE]
