Stop playback of the sound on clicking a button?

Hello

I found this code to play sounds:

  1. myButton_btn.addEventListener (MouseEvent.CLICK, buttonIsClicked);
  2. function buttonIsClicked(event:Event):void
  3. {
  4. var sndcontext:SoundLoaderContext = new SoundLoaderContext (4000);
  5. var snd:Sound = new Sound (new URLRequest ("http://www.yourdomain.com/yoursound.mp3"), sndcontext);
  6. var sndchannel:SoundChannel = snd.play (0,1000);
  7. sndchannel.soundTransform = new SoundTransform (0.2, 1);
  8. }

I had this works well, but I was wondering how to program a function to another button to stop to stop playing this sound?  I tried a function with snd.stop (); but this seems to be incorrect.

Thanks for your help guys.

Shaun.

Ah. Create a new actionscript file and place the script in there. Then name the file PlaySound.as. Instead of biz by package. Flashscript.Media eliminate biz. Flashscript.Media. now that the file in the same place as your fla file and try again.

Tags: Adobe Animate

Similar Questions

  • IPhone 6 produces the sound by clicking in the right corner and same dust is collected

    IPhone 6 produces the sound by clicking in the corner right and even the dust is collected!

    Can you describe the issue in more detail? When exactly it happens? Take your device at the Apple Store for further diagnosis.

  • Cannot import video from Sony handycam HD. start the button market orders / stop playback of the camera but no pictures or sound appear on the Editor screen.

    I can't import video from Sony Handycam HD 1080. Start button on the editor controls playback of the camera, but no image appears on the screen of the editor. Thnx

    andypfaris

    What version of Premiere Elements you are using and on what computer operating system is running?

    You doing DV or HDV firewire capture of data in a Capture of the first Hare elements window? What is your

    What is your predefined project?

    Is it a "it worked before but not now" show or "it never worked before"?

    Thank you.

    RTA

  • Game stops playback of a sound

    I have a class in my project called flash "resource" that I have designated to contain all the external files outside of the flash document. When I play a sonud of this class, it seems that my program will stop until the sound is fully charged, and then whenever he plays after that it doesn't lag at all. Is there a way to load the sound at another time, i.e. at the beginning of the program, rather than on the fly? Here's the code for Resource.as and how I play the sound.

    Class "Resource" (I cut out unimportant stuff)

    [code]

    package {}

    public final class Resource

    {

    [Embed (source="/Resources/Sound.mp3')]

    public static const Sound: Class;

    public void Resource()

    {

    }

    }

    }

    [/ code]

    And that's how I call the sound and play:
    [code]


    private var soundCoin:Sound = new Sound();


    public void User() {}



    soundCoin = new Resource.Sound;












    }

    [/ code]

    And, of course, I play the sound using soundCoin.play ();

    I would have simply not the right settings, perhaps because I improvised somehow what I was doing. If this method is ineffective, I'd love for people to give suggestions.

    Thank you

    use:

    private var soundCoin:Sound = new Resource.Sound ();
    public void User() {}
    }
  • How can I stop randomly ding-* the sounds coming from my computer?

    Help! Every two hours, I get a random ringing * sound of my desktop computer, if there is a web page open or not. The sound comes from speakers but is not related to the speakers themselves. The sound is the "notify" windows wave sound, like a "ding *.»  It happens totally randomly, without warning and without apparent reason. Can someone help me remove it? I use Windows 7. Thank you!

    Look in the event viewer for event occurring at that time there

  • Simulation-passage to the next without clicking any button slide

    I wanted to create a simulation, I thought that it moves to the next slide automatically and only if I want to include a button or something that the user must click on then this action would really click to the next slide.

    But in my case I have to almost always click the next or the play button, which is annoying. is it possible to fix this?

    Thanks for help.

    One of the two typical interactive objects that Captivate is inserted into a training simulation: a text entry area. Simulation is waiting for the user to enter the correct text in the TEB and use Enter to confirm. What is the problem with that? The other typical object is a click box on a 'hotspot' which must be clicked by the user. These two objects will be paused until the user interaction was made the slide.

  • With the help of A6, must create menu screen which allows the user to click a button creates a branch to other screens and return to the main menu. When returning to the main screen on which button will be gray or inactive.  How can I do this?  I created

    I am trying to imitate a piece of equipment.  I need the user to be able to click on the specific buttons that have the user to another or screens.  After viewing these screens that will be the user to the main screen where the user which buttons were pressed and which still needed to be pressed.  I create buttons image with the 3 States - who has worked except when the user returns to that slide is reset to zero, and if the user does not see the 3rd State of the button.  How can I get this 3rd State of stay after the user returns to the main screen?

    You can not 'keep' a State, that's what I said in my first answer: "you can create an image with that look of '3' State, make it invisible and show it with the same action when a button is triggered. You will need to insert extra that third picture, first hide it out and make it visible to the advanced action, which I explained. I called this additional 'Done_one' image in the example. The three States you're talking about are in a totally different way to Captivate: for down, more and up-state. You can just tell Captivate to keep a low State, it will be down when the button is pressed. Where my explanation of an additional image.

    No need for all the variables. Looks like you have a lot to learn about variables and advanced actions. I don't see another easy way to achieve what you want. It is not so difficult, tons of examples on my blog.

  • How to disable the sound of click button?

    I tried to disable this by default clicking sound with buttons. (Interactions > button)

    There was a lot of references on the internet to disable sound from the properties/options button. I don't see this option in Captivate 8 or 9.

    Does anyone know if it is still possible?

    Thank you!

    2015-10-07_10-43-59.png

    You can do it from the properties of the Action Panel, select the option to disable the clicking sound.

    Jake

  • Bridge stops responding to the Wacom stylus clicks in Windows 8

    When I use Adobe Bridge with the pen Wacom (Intuos 5) work first one or two clicks but then the program stops responding any pen clicks until I move the mouse or press the touchpad, and then all of the clicks on which are read at the same time. This problem appeared with Bridge CS5. So, I upgraded to CS6 hoping he would go, but he didn't. Now, I downloaded the new version of the CC of the bridge and it does the same thing. The pen works irregularly in other Adobe programs like this but the anomaly is even more evident and occurs regularly in bridge. All Microsoft programs (Office 2010, Outlook, Internet Explorer and Windows 8 itself) work fine with the Wacom pen.

    I searched the Adobe and Wacom support forums and this problem does not seem to have an impact on everyone. Although, I found these two posts by people with similar problems:

    http://forums.Adobe.com/message/5359741

    http://forums.Adobe.com/message/5262754

    I talked to Wacom tech support and tried all the troubleshooting steps they might think, including going back to earlier versions of the Intuos driver. They have released a new driver Windows 8 yesterday (6.36) but it did not solve my problem.

    Since I'm using a Logitech mouse, I tried the update and completely uninstall the Logitech drivers back to earlier versions, but the problem has not disappeared. I also uninstalled, cleaned the parameters and reinstalled Adobe applications several times without any change.

    This morning I tried to disable all non-Microsoft services and all non-essential programs start on reboot, but it made no difference.

    A clue, I noticed which may help the Adobe engineers to understand this mystery, is that when I click on the small triangles to extend the metadata in the Panel (with my first click Pen because it is the only one that records) they will highlight but not turn and the Panel never develops (see photos below). It is a unique behavior, which I can't reproduce with my mouse. If someone can identify what would make the triangles react in this way, we could be on what message the program is when I click with the pen.

    bridge-1.jpg

    After the pen click metadata Camera Raw triangle

    bridge-2.jpg

    After the mouse, click on metadata Camera Raw triangle

    For me the problem has not returned since I turned on Windows 8 "keep" in the Panel "Pen and Touch. Latest Wacom drivers have a checkbox 'Use Windows Ink' which seems to do the same thing (and replaces Windows settings that a "hold" on by default.)

    So what I suggest try, BrightWork, turns 'press and hold' Windows 8 (Control Panel / settings of the Tablet PC / Goto Pen and Touch / Pen Actions / press and hold /Settings / activate) and off in Wacom driver (uncheck "Use Windows Ink" under the pen of mapping).

  • When I close Windows Media Player he doesn't stop playback of the MP3 playing.

    My Windows Media Player in windows vista family premium is not working properly. When I open an mp3 file, it starts in the background & also if I close the media player, it is not down. He's playing the media. Even when I find it in the Task Manager to close, I think.  Help please.?

    original title: WINDOWS MEDIA PLAYER DOES NOT WORK PROPERLY

    Hello

    1. have you made changes on the computer before this problem?

    2. do you get any error code or error message?

    I would suggest trying the following methods and check if it helps.

    Method 1:

    Run the fixit in the following Microsoft Fixit article and check if the problem persists.

    Solve the problems of Windows Media Player video and other media or library:

    http://support.Microsoft.com/mats/windows_media_player_diagnostic/

    Method 2:

    Try to re-register the following DLL (Dynamic Link Library) files and check if it helps.

    a. click on start, all programs, and then click Accessories. Click with the right button on command prompt and select run as administrator.

    b. type the following commands one by one and press ENTER.
    regsvr32 jscript.dll
    regsvr32 vbscript.dll
    regsvr32 wmp.dll

    c. close the command prompt and check to see if the problem persists

    Method 3:

    Run the scan tool (SFC) System File Checker and check if it helps.

    How to use the tool File Checker system to troubleshoot missing or corrupted on Windows Vista system files: http://support.microsoft.com/kb/929833

    Hope the information is useful.

  • cannot force the player to stop playback of the audio file

    Hi guys,.

    I'm stuck with the pretty easy task. I have an audio player, start playing the audio file and I just want to stop it, do not wait until the player arrives at the end of the media. But nothing happens! The media playing contiunes. And there is no response at all to my call to the stop method.

    Here is my sample code. I start player and is going to stop it in 3 seconds.

      private void play(InputStream path, String type) {
    
        try {
            // create an instance of the player from the InputStream
            player = javax.microedition.media.Manager.createPlayer(path, type);
            player.realize();
            player.prefetch();
            VolumeControl volumeControl = (VolumeControl) player.getControl("VolumeControl");
            volumeControl.setLevel(100);
            // start the player
            player.start();
    
            new Timer().schedule(new TimerTask() {
            public void run() {
                try {
                player.stop();
                } catch (MediaException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                }
    
            }
            }, 3000);
    
        } catch (final Exception ex) {
            UiApplication.getUiApplication().invokeAndWait(new Runnable() {
            public void run() {
                Dialog.inform(ex.toString());
            }
            });
        }
        }
    

    BlackBerry jde 4.5.0

    device Curve 8310

    I understand where the problem was.

    So be patient while creating player and pass the correct audio type.

    In my case I have played the .wav files created with "audio/mpeg" type player. That is why all the evils.

  • Browse the photo by clicking on button oracle Developer 10 g.

    Hello...

    How are you guyz.

    I have a database name Image and type LONG ROW... I also create a form.

    I have a button... .BT problem that is my can'nt button works when I need to add pictures in a folder... When I press the button to access my drive hard he cannot work and also there is no show error...

    Can u please help me? how I can solve it...

    concerning

    Fabrice

    Hi Fabrice,.

    You need write permission in the folder C: \program files\java\jre6\bin. Check if the permission is there or not.

    Manu.

  • Stop the sound

    Hey guys,.

    I try to add two functions in a single button, first of all, it will take me to the next frame and the other stops the music being played

    I have this written already, jump to the following framework works but the stop function does not work even if the program is still running and no error message come up... help

    import flash.events.MouseEvent;

    import flash.media.Sound;

    import flash.media.SoundChannel;

    Stop();

    Create a new sound variable 'theSunSound' to the name of the given class

    the audio file in the library 'theSunSoundFile '.

    var theSunSound: theSunSoundFile = new theSunSoundFile();

    Variable set

    theSunSound.play ();

    btnGoodJob.addEventListener (MouseEvent.CLICK, bGoodJob);

    function bGoodJob(event: MouseEvent): void {}

    gotoAndStop ("Start");

    Create a new variable of channels of sounds 'theSunSoundChannel '.

    / * This is required only if the sound will do more than just play

    That is to say: stop, pause, etc... */

    var theSunSoundChannel:SoundChannel = new SoundChannel();

    / * Create a variable to store the position of the "read head".

    of "theSunSoundChannel" * /.

    var theSunSoundPausePosition:Number = new Number();

    Set the time of the "read head" to 0

    theSunSoundPausePosition = 0;

    / * Create a Boolean variable called 'theSunSoundPlaying '.

    This goes from true to false as the case

    "theSunSoundChannel" plays * /.

    var theSunSoundPlaying:Boolean = false;

    Stop playback of the variable "theSunSoundChannel".

    theSunSoundChannel.stop ();

    Change 'theSunSoundPlaying' Variable to false

    theSunSoundPlaying = false;

    / * The 'theSunSoundPausePosition' value of 0, it

    reset 'theSunSoundChannel' to read from the beginning * /.

    theSunSoundPausePosition = 0;

    }

    Yes, somehow, but you define another instance of the string inside the function.  Get rid of that too.

  • I'm not all the sounds from my computer. I tried to adjust the volume settings, but it won't let me

    The volume in the Control Panel tab is not to return me something else click 'OK' and the cursor thing is low.

    Hi leannaroma,

    1. Did you the latest changes on the computer?
    2. When was the last time it was working fine?
    3. You have security software installed on the computer?

    Method 1

    I suggest you run the troubleshooter of playback of the sounds and check if it helps.

    No sound in Windows

    http://Windows.Microsoft.com/en-us/Windows/help/no-sound-in-Windows

    Method 2

    If the previous step fails, then I suggest that you manually download and install the audio drivers on the computer by visiting the sound card manufacturer or computer manufacturer's website and check if it helps.

    How to manage devices in Windows XP

    http://support.Microsoft.com/kb/283658

  • Static and sounds by clicking on p209tx

    It's a week since I got this machine and I started experencing static sound in my headphones and external speakers, sometimes the problem is resolved automatically by itself and after restarting your PC, it comes back.

    I've tried disableing beats, but nothing happened.

    Another thing is valume has a mind of its own, it changes automatically, I mean, you would get a noise at level 20, but sometimes it isn't still audible.

    Well

    Discount windows 8.1 did not really solve the problem (cause of all my settings have been restored). So I did a reset of the system too, it does not solve the problem, but it helped me to analyze what who and where was the problem!

    So, this is what happened: -.

    I did a reset of the system and noted the the sound was nice (really nice).

    So I'll start all my software displays while listening to music and he had no problem with the sound until now, until the

    I have installed these 2 software

    (1) Virtualbox

    (2) the browser Maxthon cloud.

    (I need virtualbox I experiment with many different operating systems). I think that the problem was caused, as a sound card is shared by more than 1 os when you use virtualization (I used to run 4 operating systems in parallel, so a sound card is shared by 4 os).

    and the second thing I have that whenever I opened Maxthon browser of cloud, the sound starts clicking and poping up.

    If the problem was definitely with the browser.

    so in fact when we talk about "it's a random problem", it was when I was watching at the same time all while listening to music.

    So thanks for trying to help me. Finally I could enjoy an audio sound quality real time.

    Now, I think it sounds really good

Maybe you are looking for

  • Can't burn DVDs with my Satellite U500 (PSU9ME)

    When I try to burn a DVD, I get this message: The disc is not burned properly, make sure that you have installed the latest firmware for your CD / DVD and try again

  • OSX addon to improve open and save dialogue

    My mind is empty. Years, I used this addon for osx to improve open and save. The app has additional features, enabled a click in the finder to move to a folder full of good things. But I couldn't use it for several months with 10.11. Now I'm going to

  • VI changes/projects

    for some, with a project as a dependency of vi. My question is that I to vi in the outbuildings of the EXAMPLE: myaccount and I opened, when the project is open, clicking in the dependencies section. If I make changes to the vi, does make changes to

  • New developer

    I want to write programs to run on the operating system palm 5.4.5 (Garnett) where can I get a SDK for this

  • Problems with SmsDemo

    Hello I try to run SmsDemo. I imported the sample SmsDemo and I have the server, account component. I run the server component, but the messages that I send to the application of SmsDemo have no effect - I don't see anything happen to the account app