# Adding an Event Listener to a Sound Clip

**URL:** <https://forum.kirupa.com/t/adding-an-event-listener-to-a-sound-clip/330864>\
**Category:** flash\
**Created:** [March 30, 2013, 7:47pm UTC](https://forum.kirupa.com/t/adding-an-event-listener-to-a-sound-clip/330864 "2013-03-30T19:47:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![drdexter33](https://avatars.discourse-cdn.com/v4/letter/d/ee59a6/32.png) [@drdexter33](https://forum.kirupa.com/u/drdexter33)\
**Post date:** [March 30, 2013, 7:47pm UTC](https://forum.kirupa.com/t/adding-an-event-listener-to-a-sound-clip/330864/1 "2013-03-30T19:47:48Z")

</div>

I’m using AS 2.0 and trying to code some logic to:

1. Play a random sound clip
2. As long as the sound clip is playing, play an animation.

While I’m not an AS programmer, here’s what I have so far

```auto

stop();var clipArray = new Array();
var btnChip;
var chipHead;
clipArray[0] = "1_cd.wav";
clipArray[1] = "10_SUB.wav";
clipArray[2] = "2_cmonFrank.wav";
clipArray[3] = "3_ELANOR.wav";
clipArray[4] = "4_factory.wav";
clipArray[5] = "5_FANG.wav";
clipArray[6] = "6_hooty.wav";
clipArray[7] = "7_mqs.wav";
clipArray[8] = "8pb.wav";
clipArray[9] = "9rudys.wav";

//start function
btnChip.onRelease = function(){

gotoAndPlay(2);
chipClip = new Sound();
var randID:Number = Math.floor(Math.random()*9)+1;
chipClip.attachSound(clipArray[randID]);
chipClip.start();	
chipClip.AddEventListener(Event.SOUND_COMPLETE, chipDone);
}
function chipDone(ev:Event):void
{
   trace("sound over");
   this.gotoAndStop(1);
}

```

The compiler error is complaining at the function chipDone():void line.

Scene=Scene 1, layer=ACTIONS, frame=1, Line 39 The class or interface ‘Event’ could not be loaded.

Something is telling me I need to use AS 3.0…

Thanks in advance…

Doug
