0 Replies Latest reply on May 21, 2016 12:12 PM by camip45373509

    How to create MP3 URL for Actionscript3 button?

    camip45373509

      Hi,

       

      I'm creating a button to play/pause music when clicked. I am using code (pasted below) in which I need a URL for an MP3 for it to play. How can I create a URL that will work for this? The URL I have in the code is the MP3 that comes with the code snippet but I want to use a different MP3.

       

      Code I used (from code snippets):

       

      /* Click to Play/Stop Sound

      Clicking on the symbol instance plays the specified sound.

      Clicking on the symbol instance a second time stops the sound.

       

       

      Instructions:

      1. Replace "http://www.helpexamples.com/flash/sound/song1.mp3" below with the desired URL address of your sound file. Keep the quotation marks ("").

      */

       

       

      music_btn.addEventListener(MouseEvent.CLICK, fl_ClickToPlayStopSound);

       

       

      var fl_SC:SoundChannel;

       

       

      //This variable keeps track of whether you want to play or stop the sound

      var fl_ToPlay:Boolean = true;

       

       

      function fl_ClickToPlayStopSound(evt:MouseEvent):void

      {

        if(fl_ToPlay)

        {

        var s:Sound = new Sound(new URLRequest("http://www.helpexamples.com/flash/sound/song1.mp3"));

        fl_SC = s.play();

        }

        else

        {

        fl_SC.stop();

        }

        fl_ToPlay = !fl_ToPlay;

      }