0 Replies Latest reply: Aug 15, 2013 3:47 PM by Vladdie93 RSS

    Sound not working in Flash Builder. Help please.

    Vladdie93 Community Member

      So, here's my situation. I keep trying to put an mp3 in Flash Builder to try and make sounds happen, but each time I do it only plays the beginning of it and stops midway through. My music is working at 44100 Hz with a 32 bit rate (tried changing it to 16, but Audition won't let me). Here's my code.

       

      package

      {

       

                import flash.display.Sprite;

                import flash.events.Event;

                import flash.events.KeyboardEvent;

                import flash.media.Sound;

                import flash.media.SoundChannel;

                import flash.ui.Keyboard;

       

                [SWF(width = "550", height = "400",

                backgroundColor = "#FFFFFF", frameRate = "60")]

       

                public class SoundThing extends Sprite

                {

       

                          [Embed(source="../sounds/try1.mp3")]

                          private var Try:Class;

       

                          private var _try:Sound = new Try();

                          private var _tryChannel:SoundChannel = new SoundChannel();

       

                          public function SoundThing()

                          {

                                    stage.addEventListener

                                              (KeyboardEvent.KEY_DOWN, keyDownHandler);

                          }

       

                          public function keyDownHandler(event:KeyboardEvent): void

                          {

                                    if (event.keyCode == Keyboard.SPACE)

                                    {

                                              _tryChannel = _try.play();

                                    }

                          }

                }

      }

       

      I'm not sure what the issue is. Please help me. Thank you!