Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 09-10-2008, 04:37 PM   #1
Registered User
Join Date: Sep 2008
Posts: 1
Wink AS3 - Sound button

Hello everyone,

I have a question that I have three sound buttons click to hear a sound. It works only one button with below the code. How to make to work with three sound buttons? Looks like simple but I can't figure it out. Am I using a wrong code here? Please help me.

var loadSnd:URLRequest = new URLRequest("SORTER.mp3");
var thisSnd:Sound = new Sound();
var sndTrans:SoundChannel = new SoundChannel();


play_btn.addEventListener(MouseEvent.CLICK, playF);
stop_btn.visible = false;
stop_btn.addEventListener(MouseEvent.CLICK, stopF);

function playF(event:MouseEvent):void{
sndTrans = thisSnd.play();
play_btn.visible = false;
stop_btn.visible = true;

function stopF(event:MouseEvent):void{
stop_btn.visible = false;
play_btn.visible = true;

Any help would be greatly appreciated.

spark067 is offline   Reply With Quote
Old 09-11-2008, 03:00 AM   #2
chemicaluser's Avatar
Join Date: Aug 2008
Location: Canada
Posts: 72

not sure if i understand your question. you have 3 buttons and you want them to play the same sound when any one of the buttons is clicked, right?

if so.. the problem would be that in your code you only have one event listener
play_btn.addEventListener(MouseEvent.CLICK, playF);
you have to add the event listeners to the other buttons which are calling the playF function, basically copy the line but change the play_btn to whatever the instance name is of your other buttons is.

play_btn.addEventListener(MouseEvent.CLICK, playF);
button1.addEventListener(MouseEvent.CLICK, playF);
button2.addEventListener(MouseEvent.CLICK, playF);

and if i misunderstood your question, .... i don't know, good luck. lol

Last edited by chemicaluser; 09-11-2008 at 03:04 AM.
chemicaluser is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
sound on/off btn EdibleCastle ActionScript 2.0 2 03-27-2006 08:18 PM
Audio Sound Question Chronix2005 ActionScript 2.0 0 07-27-2005 04:18 PM
Sound FX play when Button Pressed c2kman ActionScript 2.0 0 08-05-2004 12:51 AM
Pause and Play Button controlling Movie with Sound ebmccauley ActionScript 1.0 (and below) 4 12-12-2003 03:12 PM
pause button sound issues dman ActionScript 1.0 (and below) 1 06-17-2003 08:02 AM

All times are GMT. The time now is 04:52 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.