Skip to main content
Participating Frequently
June 20, 2019
Answered

How to get the Play Music Button to work in a Published .swf file?

  • June 20, 2019
  • 1 reply
  • 894 views

I am new to Adobe Animate and AS3. And I am trying to create a button that plays music in a .swf file. I have already created two buttons: one that stops my music. and one that plays it. The code I used is below. It works in the test in Animate but does not work in Published .swf file. I would appreciate if you could tell me how to get it to work for .swf file? The stop button works fine in .swf. Final question - is there a way to get buttons to work in a .GIF?

This is the code that I am using for my buttons to stop and play music:

var mySound:Sound = new Sound();

var myURL:URLRequest = new URLRequest("audio_hero_Separate-Ways_SIPML_C-1317.mp3");

mySound.load(myURL);

music_btn.addEventListener(MouseEvent.CLICK, playSound);

stop_btn.addEventListener(MouseEvent.CLICK, beQuiet);

function playSound(e:MouseEvent):void

{

mySound.play();

}

function beQuiet(e:MouseEvent):void

{

     SoundMixer.stopAll();

}

This topic has been closed for replies.
Correct answer kglad

Mine opens in windows Media player. And then said: "Your current security settings do not allow this action". So I set mine to open in Adobe Acrobat.


no code will execute in those programs.

what are your plans for your project?

1 reply

kglad
Community Expert
Community Expert
June 20, 2019

with that code, your mp3 needs to be in the same directory as your swf.

AcE0177Author
Participating Frequently
June 20, 2019

The mp3 is in the same folder.

kglad
Community Expert
Community Expert
June 20, 2019

then your code is correct.  there must be something else making you think there's a problem.