2 Replies Latest reply on Mar 20, 2011 11:42 PM by iPixelen

    [AS3] Trigger audio clip


      Hi, I'm trying to get an audio clip to play when a movie clip is clicked, and I've used this code:


      bear_mc.addEventListener(MouseEvent.CLICK, growl);
      function growl(e:MouseEvent):void{


      I added the audio clip to bear_mc, but when I preview the video the sound clip plays automatically and when I click bear_mc nothing happens. What am I doing wrong? I'm a total beginner so please be gentle with me.

        • 1. Re: [AS3] Trigger audio clip
          robdillon Most Valuable Participant

          From your description it sounds like you have the sound attached to the first keyframe in the movieClip bear_mc. If this is the case then the sound will play as soon as that first keyframe is seen by the playback head, whether the movieClip is playing or not. If the movieClip bear_mc has more than one frame, you could add a keyframe to frame 2, attach the sound there and the sound will play when the movieClip plays. Another approach is to create a sound object and attach the sound to that. Then you can tell the sound object to play.

          1 person found this helpful
          • 2. Re: [AS3] Trigger audio clip
            iPixelen Level 1

            Ah okay, thanks for the help. I tried adding another keyframe to the timeline of bear_mc and triggering the audio clip with that but I still had the same problem, it just plays automatically. Thanks anyway! It was just meant to be a jokey thing but if it's going to be this much hassle I won't bother haha