Playing a sound by clicking a button
hello,
I'm a beginner in programming java.
now I have the problem that I don't know how two make a button playing a beeping sound if you click on it.
Is there anybody woh can help me???
thanks a lot...
if(event.getSource()==myButton) {
java.awt.Toolkit.getDefaultToolkit().beep();Hey Wat other noises can i make?
please email them to me at [email protected]
Thanks alot
Similar Messages
-
Change sounds, by clicking same button
I need to create a button, that will play one sound at a time
when it's being clicked, switching to a different sound from the
library each time it's clicked. (I have about 10 sounds at the
library I need to rotate when the user keeps clicking the button.)
I'm new to actionscript, so I apologize for not, having any
code to start with! I've looked everywhere online and can't find a
tutorial for this. Any help would be appreciated! Thanks!Actually, I got it to work - I just removed the line
s.stop( );
and I changed
s.indexVar=0;
to
s.indexVar=1;
so here's the code as it is now:
s=new Sound(this)
s.indexVar=1;
soundbtn.onPress=function(){
s.attachSound("sound"+s.indexVar++);
if(s.indexVar>9){
s.indexVar=1;
s.start();
} -
Playing multiple movies without clicking home button
I want to create a piece of art containing multiple buttons. For example, an illustration of a field, where, if the user were to click on a bush, a rabbit's head would pop out briefly, then disappear behind the bush. If a lilly pad were clicked, a frog would pop his head out of water and again disappear. How can I allow the user to randomly click on the various buttons, triggering the associated movies to play, without necessitating that a "home" button be hit after each sequence?
I can get each button to play the corresponding movie. After the movie plays, however, I would like the movie to automaticaly revert to the home state.
In this way, the user could randomly click around on the image, triggering various movies when the appropriate buttons are hit. I have seen this done many times- I remember an an image of a hanunted house, for example. When the user clicked on a window, it would open and a ghost would look out. Without having to then click a home button, a further click on the door of the house would cause the door to open, and a mummy to lean out. I'm trying to avodi having to repeatedly hit a "home" button before additional button hits could trigger additional movie clips.
I should probably mention that I've had to insert a stop command at the end of each movie clip, otherwise all the animations play sequentially, rather than one at a time, when a button is clicked. How do I tell Flash to procede from this stop command, at the end of each movie, back to home, so that further buttons can be pushed?
Sorry if I've misunderstood your posting- I've been animating for several years on Flash, but have only started several days ago to use Actionscript 3 for interactivity, and am a complete novice, in that regard. -
Play/stop sound on one button (AS3)
hello
when you click the first time on the button, it should start the song, when you click a second time on the button, it should stop the song. how do i make this with actionscript 3?
regards
simonA very basic example:
You'd need 3 var:
private var _sound:Sound;
private var _soundChannel:SoundChannel;
private var _soundChannelPosition:Number = 0;
Then create a Sound:
_sound = new Sound(new URLRequest("some.mp3"));
Stop/play the sound on click:
private function click(e:MouseEvent):void {
if(_soundChannel == null){
_soundChannel = _sound.play(_soundChannelPosition);
} else {
_soundChannelPosition = _soundChannel.position;
_soundChannel.stop();
_soundChannel = null; -
Help playing a sound file please...
i am trying to play a sound file everytime a button is clicked. the sound will play the first time the button is clicked but wont play after that. how can i get the sound file to play everytime the button is clicked?? here's how i play the sound file...
InputStream in = new FileInputStream(sound.wav);
AudioStream as = new AudioStream(in);
// in the button action event...
AudioPlayer.player.start(as);
i tried adding this line... AudioPlayer.player.stop(as);...before the...AudioPlayer.player.start(as); -- the sound file still only plays once
any help appreciated...thanksHi there,
Is there a class AudioPlayer in the API or is it yours. Anyway, your class must implement AudioClip interface. Then call yourClass.play(as); You dont need to stop, each time you call play(), it restarts. Try and let me know.
cheers -
Playing basic sound ( *.wav ) through a click of button ?
Hi Java experts:
Need to know the Java code to be added to a click button 1 to play sound ( *.wav ) and the code to stop the sound through and other click of button 2.
Using a normal applet
Thank you in advance
M C BenzerariSee...the scenario is something like this : I have a main application running into a JFrame instance. Now, from a menu item in this JFrame, I have opened the modal JDialog. And from this modal JDialog, I have created a JFrame. Now I am not able to focus and perform any operation on this JFrame unless I close the JDialog from which it was created.
Please suggest some workaround so that without closing the JDialog, I am able to fire some event from the JFrame which is being created from this modal JDialog.
Thanks,
Gauri -
Sound on/off by click a button in flex4????
hello everybody, i want to make a website by flex.in that have sound effect. i want when i load page have sound and if i don't want to listen i can click button.the sound will stop play and else. But i don't know how to make on/off sound by a button click
i done:
in actionscript file Sound_playExample1.as: i write code
package myComponents {
import flash.display.Graphics;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.ProgressEvent;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.net.URLRequest;
public class Sound_playExample1 extends Sprite {
private var snd:Sound = new Sound();
private var channel:SoundChannel = new SoundChannel();
public function Sound_playExample1() {
var req:URLRequest = new URLRequest("myComponents/soundall.mp3");
snd.load(req);
channel = snd.play(0,6);
// ActionScript file
in my Main.mxml:i write
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:MyComp="myComponents.*"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
protected function button1_clickHandler(event:MouseEvent):void
// TODO Auto-generated method stub
]]>
</fx:Script>
<fx:Declarations>
<MyComp:Sound_playExample1/>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Button x="177" y="71" label="Button" click="button1_clickHandler(event)"/>
</s:Application>
can u help me please what i have to do. if you know you can
Additional for this code.thanks// below code sinppet should go into on button click event handle method.
if
(pausePosition==0 ){ if(channel!=null){pausePosition = channel.position;
channel.stop();
sound.setStyle("icon",soundOffClass); // mute
}else{
if(channel!=null){channel.stop();
channel = snd.play(pausePosition);
sound.setStyle("icon",soundOnClass); // un mute , this should be default as
pausePosition=0; -
Can a button play a sound?
I want to have a button that's sole purpose is to make a
sound.
Can captivate do that or do I have to create a buton in flash
and import the
swf?Hi David Burley
Indeed you may. Here's how:
Insert a Button Object on your slide.
Configure the Button to do nothing when clicked. (No Action)
In the properties for the Button object, click the Options
tab.
Enable the Success caption.
Configure the Success caption to be transparent with no text.
Then click the Audio tab of the caption properties.
Select your audio clip.
The end result should be that when your user clicks the
button, the audio clip plays. But this may pose a problem. The
button can only be clicked a single time to produce the effect.
Because of this, you may wish to insert a blank slide immediately
before the slide with the button. Then program the button to jump
to the previous slide. This should "refresh" the current slide so
your button will work over and over.
Hope this helps... Rick -
How to play music when clicking a button?
Hello There
Could someone help me a bit to get started?
My first attempt is to just create a scene, in which clicking
a button it starts to play a mp3 file. I did get it to start it to
play as a backround music after reading the help file, and tried
also find source code from internet and also here without success.
So, could someone be so kind to give me a Lingo example code
snipplet, which would start playing the music immediately without
first importing the file (like streaming the file) if this is
possible and also small instructions how to assign it to the button
(so, not as a backround music).
I just got the Adobe Director 11 couple of days ago, and my
wife is starting to get angry for me for sitting with my NB all the
evenings without any progress,,,
Thanks, in case someone answers…Thanks Sean, here is some more info for your answer:
Is it imported into a cast library, or is it an external
file?
I did try it to get working with an imported mp3 file and
also I would like to add fuctionality to use it as a link.
If it's an external file, do you need to give the user the
option to
choose a file from a list (or even a different directory), or
will the
sound file to be played always exist in the same (relative)
directory
with the same name?
The best would be a possibility to choose the file, and if
it's possible to set up a starting directory (like "My Documents\My
Music" for example), so that could work as a mp3 player. -
How do i actionscript my flash button to play the sound while being transfered to another url?
Hi!
As the title says:
How do i get my flash button to play my sound when i click on
it while being transfered to another url?
I did get it to work, but only when i set the script to
"_BLANK". When i clicked the button then it played the sound and
opened the url in a new window. I want it to be in the same window
and still play the whole sound.
Now i get just 1 or 2 sec then when im transfered, it stops
playing the sound.
I hope this explains it..... if any typo....its because im
Swedish =)
Thanks in advance!If you are jumping to another URL using the same window you
cannot have a sound start on the press of a button and that sound
to continue on.
Reason
You are removing all trace of the sound and the swf that
contains that sound file.
Work arounds
1.Take a look at "frames". This way you are keeping the
container page and opening another page inside of that page.
2. Div's. again you are importing a page into a particular
area yet keeping the swf, with the sound playing, in the parent
frame. -
Playing audio sound when slide is clicked
I have a button on my first slide which links to the third slide, and I want to play a sound as soon as the third slide is opened. How do I do this?
Drag the sound file to the third slide. Select the speaker icon for it, and in the Build Inspector, set its Build In to "Start Audio". Click the More Options button to show the Build Order drawer, and use the dropdown menu to set the build to start "Automatically after transition".
-
How to play sound after clicking on an object?
Can anyone explain me how to play a sound in java when I click on a particular object? I have read lots of threads but couldn't find anything. All I want is a short sound(3,4 seconds) to be played each time I click on an object. I know I need to use Sound API but I cannot find anything helpful
Thanks in advanceflounder wrote:
ProGenius wrote:
I have read lots of threads but couldn't find anything.
[I found lots of info|http://lmgtfy.com/?q=java+audioclip]
that is knowing you can use audioclip. Even searching for "java sound tutorial" gives many good resources, including the sun trail:
http://java.sun.com/docs/books/tutorial/sound/index.html -
3.1.2 double clicking home button when music is not playing
Is the bug that double clicking home button while music is not playing didn't bring up the iPod control fixed? I don't know it's a design change or a bug, but for me it seems definitely a bug since it doesn't give anything good. Clicking home button once already terminates the application, why would anyone use double clicking to exit the application too?
This is why I'm still using 3.0. Is this fixed in 3.1.2?It's a design change, not a bug. Although I do have to agree with you on that I preferred what double-clicking the home button originally did. There is even settings (in general settings if I can remember right) on what double-clicking the home button performs, but that isn't even an option on it.
And nope this is not fixed or redesigned in 3.1.2.
Hope that answers your question,
Enjoy! -
Click a button, wait mc A to finish playing and play mc B
Hello. I am using Adobe Flash pro CS6 and AS3.
Right now I am trying to make a button to play a new mc. There are 2 movie clips. mc A and mc B.
What I want to do is my swf is playing mc A but if I click a button, it starts to play mc B, but I want to finish playing mc A before starting mc B, I mean it plays mc A (500 frames loop animation) and if I click a button on 250 frames of mc A, it waits mc A to play remaining 250 frames, and if mc A finishes, it starts mc B.
So I can not use gotoAndPlay command. What command should I use to do it?You could set some boolean variable to be true when you want mcB to play and at the end of mcA have it check the value of that variable and stop mcA/play mcB if the variable is true.
-
Playing simultaneous animations when clicking on a button
Hello,
Does anyone knows how to make two animations on the timeline in edge animate play simultaneously when i click on a button ?
I have a button in my menu, when i click on it i need to play to animations from the timeline.
Thanks for helping me.hey Vincent,
Try adding the animation to a symbols and playing the symbols. When you make these symbols have auto play un-ticked as the animation will play automatically from the start of the main timeline otherwise. Then on your button you can access the symbols by add code:
sym.getSymbol("symbolname1").play();
sym.getSymbol("symbolname2").play();
If you don't want to put the code in yourself use the auto coder and you go playback/play/stage/symbolname1
The play works the same as if it was on the main timeline so you can play from a label, time on the timeline or just leave play() to play from the beginning of the symbol.
Hope this helps
Maybe you are looking for
-
I want to import some of my iTunes files to my mother's iTunes account so she doesn't have to pay again to get them. We are going on a trip soon, and she wanted some movies to watch on here iPad. Some of the movies, I already have. I can't seem to
-
ITunes Gift Card and now "iTunes could not connect to the iTunes Store."
My wife was using my computer yesterday and was entering in a gift card number that I gave her. Well, the card had a number missing or something and she tried all types of combinations. After some time she showed me an error (-50 if I recall) and sin
-
Terms of payment - Transportation document
Dear All, We are using payment terms in our business scenario. Our payment terms will follow customer received for calculation of discount. We are using Transportation documents for shipping the deliveries. Each transportation document will applicabl
-
Hi All, I'm new to Flex, but I've been impressed with it so far. I was able to create a simple app, where things like navigation trees and table data were populated based on XML stored inside mx:XMLList tags inside the main document. In order to clea
-
How do I get to show my history in my favorites?
How do I get to show my history listings in my favorites??