# Loading Sound

**URL:** <https://forum.kirupa.com/t/loading-sound/322729>\
**Category:** flash\
**Created:** [June 1, 2011, 12:08am UTC](https://forum.kirupa.com/t/loading-sound/322729 "2011-06-01T00:08:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![LightningJoe](https://avatars.discourse-cdn.com/v4/letter/l/96bed5/32.png) [@LightningJoe](https://forum.kirupa.com/u/LightningJoe)\
**Post date:** [June 1, 2011, 12:08am UTC](https://forum.kirupa.com/t/loading-sound/322729/1 "2011-06-01T00:08:21Z")

</div>

I am in some serious need of some help. Oh, and I need some assistance writing code too.

I’ve created what is a vector replication of the face of a stereo receiver. Essentially what I have done so far is that the “power” button on the receiver “turns on” the receiver. Basically it jumps to a new frame and displays a movie clip that shows welcome text scrolling along the LED of the receiver. The code I wrote works fine:

stop();

power\_btn.addEventListener(MouseEvent.CLICK,clickListener1);  
function clickListener1(event:MouseEvent):void {  
gotoAndStop(“poweron”)  
}

Now that the power is “on”, the 6 buttons (I am using to play my 6 favorite songs) can be pressed. I have probably tried 5 or 6 different variations on the code and nothing works. I was originally able to embed the songs in Flash (bad idea… made my file 200 MB), but at least they played. They didn’t stop when I clicked a new button, but it halfway worked.

The better way is to load them externally. But I am not able to find code that works, nor do I know enough about AS3 to know how to do this. Basically, I need to write script that will play a song (loaded from an external source, same source folder as the .fla file), then stop and play the a different song when a new button is pressed.

Everything is on the main timeline.

I’ve found this code, but it’s not working.

var snd:Sound;  
var channel:SoundChannel;  
var trans:SoundTransform;

// Array of all the songs in the current playlist.  
var songList:Array=new Array(“metallica.mp3”,“audioslave.mp3”,“ledzeppelin.mp3”,“soundgarden.mp3”,“stones.mp3”,“greenday.mp3”);

fav1music1.addEventListener(MouseEvent.CLICK,clickListener1);  
function clickListener1(event:MouseEvent):void {  
gotoAndStop(“tunes”)  
}
