473,480 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Click a Button Symbol to play an .mp3 clip

1 New Member
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?
Aug 10 '08 #1
3 4492
nomad
664 Recognized Expert Contributor
what version of flash are you using.
and do you want to stream the mp3 clip or have it embed in flash.

nomad
Aug 16 '08 #2
maximillion511
22 New Member
go here

if i read what youre saying correctly, go to the URL above
Aug 19 '08 #3
bnashenas1984
258 Contributor
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
Sep 4 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
5521
by: yihan | last post by:
Hi, I would like to make a pageUp and pageDown button to go up or down in the text ( it is like PgUp/PgDown on the keyboard). But it works on the IE but not on netscape 7.1. Could somebody tell me...
18
6026
by: nutso fasst | last post by:
Hello. Is there a way to make an element 'transparent' to mouse activity, such that mouse events go to the underlying element? I have an absolutely-positioned image element with transparency...
1
1728
by: pmclinn | last post by:
The code below is generated by an application that allows you to put a Microsoft assistant on a webpage. I'm having a heck of a time trying to get this script to launch on a server side button...
24
11338
by: aam | last post by:
hi, im trying to figure out how i can program the mouse to automatically click on a button of a web page that i'm viewing.i do not have control over the page.i would also like to set up an...
3
4259
by: groovymovin | last post by:
Hi there, I am a newbee. searched intensively for a quite simple problem but couldnt find an answer. Here is my problem: I have two layers with 2 movie clips. The movie clip on layer 1 stays...
2
1789
by: ilamathi | last post by:
While converting to symbol we have the options to choose with graphic and movie clip,under which circumstances we should graphic /movie clip?Is there any condition to choose it?Plz clear my doubt!
4
17125
by: winterdream28 | last post by:
i am new to action script 3.0, i am somewhat familiar with 2.0 and can not for the life of me piece together the coding to make a roll/over and then a roll out animation on a button. I see it quite...
5
3165
by: Katt | last post by:
first of all I am new to flash. I just started to use CS3, and I have 2.0 actionscript selected Cannot get my MC button instance to go play a movie clip on another frame, I have tried...
8
2824
by: chromis | last post by:
Hi, I've been struggling to get sounds to work with attachSound when the sounds are stored in a swf loaded into another swf. I came across a post on a forum which supposedly explains how to to do...
0
6908
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7043
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7081
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6737
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6921
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5336
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4776
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4481
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
179
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.