Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old August 10th, 2008, 03:54 PM
Newbie
 
Join Date: Aug 2008
Posts: 1
Default Click a Button Symbol to play an .mp3 clip

What actionscript do I need to add to have a user click on a button symbol to play a 30 second music clip (mp3 file) in Flash MX 2004?
Reply
  #2  
Old August 16th, 2008, 04:53 AM
nomad's Avatar
Expert
 
Join Date: Mar 2007
Location: CA.
Posts: 562
Default

what version of flash are you using.
and do you want to stream the mp3 clip or have it embed in flash.

nomad
Reply
  #3  
Old August 19th, 2008, 08:59 PM
Newbie
 
Join Date: Jul 2008
Posts: 22
Default

go here

if i read what youre saying correctly, go to the URL above
Reply
  #4  
Old September 4th, 2008, 04:59 PM
Familiar Sight
 
Join Date: Sep 2007
Posts: 194
Default

Here is the code you need for AS3 to be able to play a mp3 file when a button is clicked

Lets say we have a button on the stage called "myButton_btn"


Expand|Select|Wrap|Line Numbers
  1. myButton_btn.addEventListener(MouseEvent.CLICK, buttonIsClicked);
  2.  
  3. function buttonIsClicked(event:Event):void
  4. {
  5. var sndcontext:SoundLoaderContext = new SoundLoaderContext(4000);
  6. var snd:Sound = new Sound(new URLRequest("http://www.yourdomain.com/yoursound.mp3"), sndcontext);
  7. var sndchannel:SoundChannel = snd.play(0,1000);
  8. sndchannel.soundTransform = new SoundTransform(0.2, 1);
  9. }
  10.  
And here are details for this script

SoundLoaderContext(4000) is the limit of your buffer. This means that your sound must be buffered at least 4000 milliseconds (4 seconds) to be played.

snd.play(0,1000) shows how many times your music should be played

SoundTransform(0.2, 1) the fist number shows the volume of your sound and the second one shows the balance on your speakers . Between -1 and 1 for left and right balance on your speakers

Hope it helps

Good luck
Reply
Reply

Bookmarks

Thread Tools

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 Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles