Results 1 to 12 of 12
-
September 11th, 2006, 06:18 AM #112Registered User
postsPlay sound on click of a button
I want to play a sound on click of a button. I can do this in AS 2.0
//Action Script 2.0
//Action Script 3.0Code:snd=new Sound(); snd.attachSound("try"); snd.start();
Thanks...Code:var snd:Sound = new Sound(); //what will come here, as .attachSound() is not there in AS 3.0 snd.play();
-
September 11th, 2006, 10:11 AM #212Registered User
postsThis works:
Code:var snd:Sound = new Sound(); snd.load(new URLRequest("my.mp3")); snd.play();
-
July 21st, 2007, 03:33 PM #31Registered User
posts
-
January 17th, 2008, 08:23 AM #41Registered User
posts
-
January 17th, 2008, 08:28 AM #532Registered User
postssound works just as movieclips, create a sound in the .fla, use the linkage dialog in teh library and set Class to: "MySound1"
then use it with:
var snd:MySound1= new MySound1();
snd.play();
should work..
-
February 12th, 2008, 12:06 AM #68Registered User
postsWhile scouring as3 forums lately there's something I've been noticing people don't understand:
Not everyone is compiling from Flash.
So just keep that in mind while you all try to be helpful.
P.S. sorry I can't help, I'm looking for the answer too. As well as some way to work with opentype fonts using code instead of linkage
-
April 9th, 2009, 03:57 AM #720Registered User
postsI also want to play sound at the click of a button, but am new to AS3 and don't know how to attach the above code to the actual button. I was wondering if someone could help me combine the following:
Thanks for your help!Code:var snd:MySound1= new MySound1(); snd.play(); soundbutton_MC.addEventListener (MouseEvent.CLICK, soundbutton_Handler); function soundbutton_Handler (e:MouseEvent):void { // this is where I need to tell it to play the sound ; }
-
April 9th, 2009, 04:15 AM #8
-
April 9th, 2009, 06:18 AM #920Registered User
poststhanks so much psych... such a simple thing but it pointed me in the right direction and now I have lots of buttons all happily playing their soundbites
-
April 9th, 2009, 02:42 PM #10
-
December 2nd, 2010, 01:21 PM #111Registered User
postsJavaScript to control the audio?
Is it possible to use a Flash audio player like this, but have something like onClick send the actual MP3 file names to the player. I am trying to build a page with a single Flash MP3 player that would then use JavaScript onClick interactions. There would be several photos on each page and the users would just click on the photos to play a different sound for each one. My goal is to only have one Flash audio player that plays MP3 files and I have been trying to use FlashVars, but just can't seem to make the connection yet.
-
July 15th, 2011, 07:38 AM #1220Registered User
posts
Hi,
I just used this code to get my sound play and added some functions. On button press the sounds starts playing or stops. But once it reached the end I can't get the sound play again, just when I reenter the frame from a different one. Help would be great.
Code:stop(); var sound:CCTVSound = new CCTVSound(); var soundChannel:SoundChannel; var soundChannelPosition:Number = 0; var playSound:Boolean = false; //this is what I thought should help to see if the end of the sound is reached to allow to play again, but don't know how to finish the code... announcement_btn.addEventListener(MouseEvent.CLICK, playAnn); function playAnn(e:MouseEvent):void { if (soundChannel == null) { soundChannel = sound.play(soundChannelPosition); } else { soundChannelPosition = soundChannel.position; soundChannel.stop(); soundChannel = null; } }Last edited by Maupa; July 15th, 2011 at 09:23 AM.

Reply With Quote


Bookmarks