Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Play audio onClick

Participant ,
Jan 16, 2017 Jan 16, 2017

Hi,

I've been trying to get some music to play when the user clicks (its for a mute and unmute button)

I've got the mute button to work with the stop all sounds code snippet. I tried to adapt it and this is what I have:

//unmute sound

instVolOn.addEventListener(MouseEvent.CLICK, Unmute);

function Unmute(event:MouseEvent):void

{

  SoundMixer.Playl(welcomeMusic.mp3);

}

Safe to say it didn't work, can someone help?

Thanks,
Jack

1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jan 16, 2017 Jan 16, 2017

It's difficult to tell exactly what you are attempting from your code. If you have created a sound object and attached a sound file from your movie's Library to that sound object then you should play and pause or stop that sound through the sound object. If your sound is embedded into a layer on your timeline then you can stop the sound through the SoundMixer object but you can't play it. The sound is playing wild on the timeline and once it's stopped it stays stopped.

Here's an Adobe help file t

...
Translate
Contributor ,
Jan 16, 2017 Jan 16, 2017

I don't think "Playl" is a real word. I tried googling "SoundMixer.Playl", and this forum post was the only result I could find.

Perhaps delete the "l"?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 16, 2017 Jan 16, 2017

After I posted I noticed the l and removed it from my code and it still didn't work - thought it was a rookie mistake!

Thanks,
Jack

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jan 16, 2017 Jan 16, 2017

try "play" with lowercase "p"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jan 16, 2017 Jan 16, 2017

try "play" with lowercase "p"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 16, 2017 Jan 16, 2017

It's difficult to tell exactly what you are attempting from your code. If you have created a sound object and attached a sound file from your movie's Library to that sound object then you should play and pause or stop that sound through the sound object. If your sound is embedded into a layer on your timeline then you can stop the sound through the SoundMixer object but you can't play it. The sound is playing wild on the timeline and once it's stopped it stays stopped.

Here's an Adobe help file that explains working with sounds in detail: http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7d21.html

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 16, 2017 Jan 16, 2017

Hirobdillon​​,

I think you're right - as I'm new to this I didn't know having the sound as a layer couldn't be played once stopped. I've had a look at the article and I think that's going to be my best answer.

Thanks Q4T​ for the suggestions too!:)

Thanks,
Jack

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 16, 2017 Jan 16, 2017
LATEST

You can restart sounds fine using a two-frame movieclip. Sound in first frame as Start or Event, then a keyframe and a stop statement in the second frame. To restart the sound just tell the clip to play again.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines