Copy link to clipboard
Copied
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();
}
no code will execute in those programs.
what are your plans for your project?
Copy link to clipboard
Copied
with that code, your mp3 needs to be in the same directory as your swf.
Copy link to clipboard
Copied
The mp3 is in the same folder.
Copy link to clipboard
Copied
then your code is correct. there must be something else making you think there's a problem.
Copy link to clipboard
Copied
Well when I watch the Published .swf file the play music button does not work. I was using adobe acrobat DC to open the .swf
Copy link to clipboard
Copied
there's something on your computer causing the perceived problem what's your computer's flash player version?
Copy link to clipboard
Copied
in adobe animate in publish setting it said Flash Player 30.
Copy link to clipboard
Copied
and when I go into control panel in Flash under updates it said NPAPI Plug-inVersion: 32.0.0.207
Copy link to clipboard
Copied
when you click your swf, it should open in your os flash player (if you have one). or does it open in your browser?
if it opens in your browser, it's a browser issue/setting. if it opens in your os player, you'll see something like:
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
no code will execute in those programs.
what are your plans for your project?
Copy link to clipboard
Copied
I am just making this project for fun, and to see what I can do in adobe animate.
Thank you very much for your help.
Copy link to clipboard
Copied
you’re welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now