# Check if external sound file exists

**URL:** https://forum.kirupa.com/t/check-if-external-sound-file-exists/329830
**Category:** flash
**Created:** [October 21, 2012, 7:09pm UTC](https://forum.kirupa.com/t/check-if-external-sound-file-exists/329830 "2012-10-21T19:09:55Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![hunsnowboarder](https://avatars.discourse-cdn.com/v4/letter/h/7ea924/32.png) [@hunsnowboarder](https://forum.kirupa.com/u/hunsnowboarder)
#### Post date: [October 21, 2012, 7:09pm UTC](https://forum.kirupa.com/t/check-if-external-sound-file-exists/329830/1 "2012-10-21T19:09:55Z")

</div>

Hi there Everyone! I have a very basic problem with sound.  
Here is my problem:  
I have an swf file which has a sound loaded in the library. It might or might not have another sound in the same directory. So what I would like the swf to do is:  
if there is a sound file in the directory then play it  
if there is no sound in the directory then play the one in the library.

My code looks like this:

```auto

var punchSoundReq:URLRequest;
var soundPunch:Sound;
punchSoundReq = new URLRequest("punch.mp3");

if (punchSoundReq){
                soundPunch=new Sound(punchSoundReq);
                soundPunch.play();
} else {
                var punchSound:Punch = new Punch();
                punchSound.play();
}

```

Of course I keep getting error message if I the punch.mp3 does not exist in the directory. What I tried to do with the if statement is to check wether the file exists…but obviously my solution does not work (because the URLRequest will be always true). How could I check for the sound file if exists?

Thank you for your help in advance!
