How to prevent a Button from playing a Sound overlaped?

I have a Button named "Bt1P" that when I click on it, the Sound "S1.mp3" begin to play.
This is the code:
Bt1P.addEventListener (MouseEvent.MOUSE_DOWN, Bt1PDown);
function Bt1PDown (event:MouseEvent):void {
clicked = 1;
  var str:String = "S1.mp3";
    var ClassRef:Class = Class(getDefinitionByName(str));
  var playSound:* = new ClassRef();
  playSound.play();       
My question is, what is the right code to tell this Button not to repeatedly play "S1.mp3" while it is already Playing!
because when i click it for the 2nd and 3rd time, the file overlaped, and 3 same sounds play together at once....you know what I mean?
any Help please??....thanks a lot.

Hey Pouradam! How are you!!
I found the answer myself....I just need to Add the RED code as below :
Bt1P.addEventListener (MouseEvent.MOUSE_DOWN, Bt1PDown);
function Bt1PDown (event:MouseEvent):void {
  clicked = 1;  
  SoundMixer.stopAll();
  var str:String = "S1.mp3";
  var ClassRef:Class = Class(getDefinitionByName(str));
  var playSound:* = new ClassRef();
  playSound.play();       
Hope it solved my problem??  Yes It did!

Similar Messages

  • [Flex 4.5.1] How to prevent Radio Button from being selected when clicked on? No Changing Event?

    I have a very common use case where you have a few radio buttons and only one can be selected at a time. Some of them are basic and on click should be selected right away, but other are more complex and open a pop up which requires some additional user selections after which the user selected OK or CANCEL for example and only after that the selection of the radio button should be applied programatically.
    So to solve this issue I've come up with 2 workarounds:
    1) make the entire group, that holds the radio button, act as a button with buttonMode="true" mouseChildren="false" and programatically change the radio button within it.
    2) hold the current radio button selection in a variable and in the changeHandler of that radio button return the selection back to what was selected before. But this also causes a small flickering of the radio button which gets selected and deselected immediately after that.. not cool.
    So my question is... is there something I am missing that could do the job without these workarounds... like a Changing event which I use for the ButtonBar but I can't find on the RadioButton or RadioButtonGroup... thanks!

    Hi,thanks for the reply. Actually that was my third option, but not sure if it's very good also..
    Here is a simple scenario:
    User must select between 2 radio buttons:
    1) no volume -> sets variable volume=0 and selects the radio button (that is the normal use case)
    2) set volume -> opens up a pop up with a list that has a X button to close and 4 options: 25% volume, 50% volume, 75%, 100%
    At this point the set volume radio button should not be selected and the user has 2 choices:
    -> hit the X button to close - nothing changes and no volume radio button is still selected and volume is still = 0
    -> hit one of the volume % buttons -> the set volume radio button gets selected and the variable volume=25/50/75/100 depending on the button selected by the user.
    That's a pretty common scenario and it's bugging me that I can't easily alter the radio button selection logic since whenever I click it, it gets selected and I can't put a logic in between in a standard way. This should apply to any component with selection, just like ButtonBar has it with the Changing event.
    So is there any other more convenient way to accomplish this scenario that you could recommend?
    Thanks!

  • How to prevent Apply button from automatic execution

    I'm using OBIEE 11.1.1.5.
    When user enter my dashboard he can see section with many prompts and some chart based reports below.
    Usually, when entering the page the reports are executed with default prompts values and it may take a while.
    Only after most of reports are being generated, user is able to open the listboxes in the prompts and select his desires.
    The listbox is not filled quick since the DB is busy on the reports execution.
    My question is:
    Can I prevent the reports to be executed automatically when entering the dashboard?
    I would like user to click on Apply in order to get results.

    Hi,
    Tune up your RPD,
    Make sure that joins are implemented correctly,
    use cache management to increase the performance to load.
    login to em and in overview you will get the cache management their also u can increase the performance
    even in RPD also u can tune the cache management to increase the perfrmance.
    Regards
    VG

  • How do I stop Firefox from playing video after I navigate from the page or leave Firefox?

    Simple and annoying. . Extremely frustrating issue with Firefox for Android. ..
    I watch a YouTube video or any flash video. . And after I hit play, the ONLY way to stop it is to hit pause or let it play to the end or close the tab. .
    It will NOT automatically stop if I open another tab. or if I navigate from Firefox. .
    I feel this is a very basic feature. Did I set something up that was wrong?
    Can I ask two questions?
    I have another extremely annoying and frustrating problem with Firefox for Android.
    The "top" (if you pull down the tabs) search bar DOES NOT allow my stock Samsung keyboard to auto space. . Thus instead of typing
    "How do I stop Firefox from playing video after I navigate from the page or leave Firefox?"
    I'll type in
    "HowdoIstopFirefoxfromplayingvideoafterInavigatefromthepageorleaveFirefox?"
    Unless I manually got the space bar.
    Using a recently factory data reset Samsung Galaxy s4 active.. android 4.2.2 and stock Samsung keyboard ... Firefox 34.0.1
    Thanks in advanced.
    Ps
    I was a hardcore xscope user for years and just recently gave in to Firefox when i lost all my bookmarks due to a forced factory data reset. .

    I'm using a different keyboard which works fine in the most top search bar...
    I cannot believe that it's not a feature.
    What if I was watching a video and wanted to shut it off quickly? I'll have to hit back? Wait for the previous screen to load then hit the power button?
    Please tell me that feature ids soon to come

  • How to prevent a file from stripping?

    I'm building vacation for Arch64 but should be the same for 32bit. PKGBUILD looks like this:
    # $Id: PKGBUILD,v 1.1 2004/01/21 15:43:15 dale Exp $
    # Maintainer: dale <[email protected]>
    pkgname=vacation
    pkgver=1.2.6.1
    pkgrel=1
    pkgdesc="an automatic mail-answering program"
    depends=(gdbm)
    url="http://www.tosn.org/projects/vacation/"
    source=(http://www.tosn.org/projects/vacation/files/$pkgname-$pkgver.tar.gz vacation.patch)
    build() {
    cd $startdir/src/$pkgname
    mkdir -p $startdir/pkg/usr/{bin,man/man1}
    # keeps binary from building
    rm -rf vacation
    # fixing the Makefile - not only for arch64
    sed -i -e 's: -m486::; s:CFLAGS.*= (.*):CFLAGS += 1:' $startdir/src/$pkgname/Makefile
    sed -i -e "s:/usr/bin:$startdir/pkg/usr/bin:g" $startdir/src/$pkgname/Makefile
    mv vacation.man vacation.1
    make install
    These file have been created:
    [andyrtr@workstation64 vacation]$ ls -lRA pkg/
    pkg/:
    insgesamt 0
    drwxr-xr-x 4 andyrtr users 96 2006-01-28 09:32 usr
    pkg/usr:
    insgesamt 0
    drwxr-xr-x 2 andyrtr users 96 2006-01-28 09:32 bin
    drwxr-xr-x 3 andyrtr users 72 2006-01-28 09:32 man
    pkg/usr/bin:
    insgesamt 24
    -rwxr-xr-x 1 andyrtr users 16864 2006-01-28 09:32 vacation
    -rw------- 1 andyrtr users 470 2006-01-28 09:32 vaclook
    pkg/usr/man:
    insgesamt 0
    drwxr-xr-x 2 andyrtr users 48 2006-01-28 09:32 man1
    pkg/usr/man/man1:
    insgesamt 0
    [andyrtr@workstation64 vacation]$
    I get this error:
    ==> Starting build()...
    gcc -march=x86-64 -O2 -pipe  -Wall  -Xlinker -warn-common -D_PATH_VACATION="/var/abs/extra/system/vacation/pkg/usr/bin/vacation" -o vacation vacation.c -lgdbm
    install -s -m 755 vacation /var/abs/extra/system/vacation/pkg/usr/bin/vacation
    install -s -m 755 vaclook /var/abs/extra/system/vacation/pkg/usr/bin/vaclook
    strip: /var/abs/extra/system/vacation/pkg/usr/bin/vaclook: File format not recognized
    install: strip fehlgeschlagen
    make: *** [install] Fehler 1
    ==> ERROR: Build Failed.  Aborting...
    Krusader detects it as a Perl program. Any idea?
    AndyRTR

    Posted: Sat Jan 28, 2006 8:45 am    Post subject: How to prevent a file from stripping?
    I'm building vacation for Arch64 but should be the same for 32bit. PKGBUILD looks like this:
    Code:
    # $Id: PKGBUILD,v 1.1 2004/01/21 15:43:15 dale Exp $
    # Maintainer: dale <[email protected]>
    pkgname=vacation
    pkgver=1.2.6.1
    pkgrel=1
    pkgdesc="an automatic mail-answering program"
    depends=(gdbm)
    url="http://www.tosn.org/projects/vacation/"
    source=(http://www.tosn.org/projects/vacation/files/$pkgname-$pkgver.tar.gz vacation.patch)
    build() {
       cd $startdir/src/$pkgname
            mkdir -p $startdir/pkg/usr/{bin,man/man1}
            # keeps binary from building
            rm -rf vacation
       # fixing the Makefile - not only for arch64
       sed -i -e 's: -m486::; s:CFLAGS.*= (.*):CFLAGS += 1:' $startdir/src/$pkgname/Makefile
       sed -i -e "s:/usr/bin:$startdir/pkg/usr/bin:g" $startdir/src/$pkgname/Makefile
       mv vacation.man vacation.1
       make install
    These file have been created:
    Code:
    [andyrtr@workstation64 vacation]$ ls -lRA pkg/
    pkg/:
    insgesamt 0
    drwxr-xr-x  4 andyrtr users 96 2006-01-28 09:32 usr
    pkg/usr:
    insgesamt 0
    drwxr-xr-x  2 andyrtr users 96 2006-01-28 09:32 bin
    drwxr-xr-x  3 andyrtr users 72 2006-01-28 09:32 man
    pkg/usr/bin:
    insgesamt 24
    -rwxr-xr-x  1 andyrtr users 16864 2006-01-28 09:32 vacation
    -rw-------  1 andyrtr users   470 2006-01-28 09:32 vaclook
    pkg/usr/man:
    insgesamt 0
    drwxr-xr-x  2 andyrtr users 48 2006-01-28 09:32 man1
    pkg/usr/man/man1:
    insgesamt 0
    [andyrtr@workstation64 vacation]$
    I get this error:
    ==> Starting build()...
    gcc -march=x86-64 -O2 -pipe -Wall -Xlinker -warn-common -D_PATH_VACATION="/var/abs/extra/system/vacation/pkg/usr/bin/vacation" -o vacation vacation.c -lgdbm
    install -s -m 755 vacation /var/abs/extra/system/vacation/pkg/usr/bin/vacation
    install -s -m 755 vaclook /var/abs/extra/system/vacation/pkg/usr/bin/vaclook
    strip: /var/abs/extra/system/vacation/pkg/usr/bin/vaclook: File format not recognized
    install: strip fehlgeschlagen
    make: *** [install] Fehler 1
    ==> ERROR: Build Failed. Aborting...
    Looks like its tring to install to /var/abs/extra/system/vacation/pkg/usr/bin....... ????
    try make DESTDIR=$startdir/pkg/usr install

  • Having trouble with iTunes playing on my phone...how do I adujust playlist from playing same song over and over...driving me crazy!....

    having trouble with iTunes playing on my phone...how do I adujust playlist from playing same song over and over...driving me crazy!....

    Check and make sure the repeat indicator isn't set to repeat the same song.  It will have a little number 1 inside a circle on it if it is. Just keep hitting it until it goes white.  It will cycle through repeat all, repeat 1, and repeat none.

  • 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.

  • How to code a button to play and pause sound using load sound?

    how to code a button to play and pause sound using load sound?I have used load sound methos to attach the sound.Can anyone help me?

    Hey thnx,
    I have used this code on sound's button's frame.and my stop n play button is on another screen.main sound button and stop button is on diffrent screen.
    Here is my code-
    stop();
    adaDrut1.onRelease = function () {
              mySoundC = new Sound(this);
              mySoundC.loadSound("F#/Bhajni1.ark", true);
    mySoundC.onSoundComplete = function() {
    _root.mySoundC.start(0,999); }
             gotoAndPlay("play2");
            _global.myTaalLaya = "Low1";
    adaDrut1 is a sound button.And there are lot of buttons with diffrent sound.
    Thanks..

  • Any one know how to stop iTunes movies from playing menu music when movie is paused?

    Anyone know how to stop iTunes movies from playing menu music when the movie has been paused?

    JourneyMan24 wrote:
    Anyone know how to stop iTunes movies from playing menu music when the movie has been paused?
    Can't. This is done for the individual movie, not by iTunes.
    Some have it, most don't.

  • How to prevent (X button) closing window

    Hi!
    I am wondering how to prevent X button on
    the right top corner on the window closing
    the window.
    My jdev java app is intended to close window
    when user explicitly presses return button.
    That's works fine ... but how to catch
    window close event (X sys btn) and stop it?
    null

    Hi,
    You need to change the default close operation of JDialog or JFrame:
    myFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);

  • How to prevent refresh button?

    how to prevent refresh button?
    ould anybady know pls tell it me

    Double-posted. See reply on http://forum.java.sun.com/thread.jspa?threadID=715948&tstart=0

  • Can someone provide a simple button which plays a sound for ios?

    I need a sample fla or the code for a button that plays a sound when touched, adobe air for ios.
    I have tried multiple tutorials and nothing seems to go right.
    a sample fla would be awesome.
    i used to be an actionscript 2 programmer so everything is new to me in actionscript 3.

    actually i just seen you cant put actionscript for iOS...is that true?
    well to develop this for android i have this code.
    but when i hit the button nothing plays, yet it plays find on the computer.
    import flash.events.MouseEvent;
    import flash.media.Sound;
    import flash.net.URLRequest;
    Multitouch.inputMode=MultitouchInputMode.TOUCH_POINT;
    var mySound1:Sound = new Sound();
    var mySound2:Sound = new Sound();
    var myChannel:SoundChannel = new SoundChannel();
    mySound1.load(new URLRequest("myFavSong.mp3"));
    mySound2.load(new URLRequest("myFavSong2.mp3"));
    mission_btn.addEventListener(TouchEvent.TOUCH_TAP, onClickPlay1);
    stop_btn.addEventListener(TouchEvent.TOUCH_TAP, onClickStop);
    ntl_btn.addEventListener(TouchEvent.TOUCH_TAP, onClickPlay2);
    function onClickPlay1(e:TouchEvent):void{
              myChannel.stop();
              myChannel = mySound1.play();
    function onClickPlay2(e:TouchEvent):void{
              myChannel.stop();
              myChannel = mySound2.play();
    function onClickStop(e:TouchEvent):void{
    myChannel.stop();

  • How to prevent my slide from advancing?

    Hi - how do I prevent my slide from advancing?  I have a text caption at the top, then 2 images, each with click boxes over them.  And then there are 2 text captions below - one underneath each image.  I also added a next button to try to stop the slide from advancing.
    I set the action on each click box to show the text caption below the image when the click box is clicked.  So here's what happens:
    - the slide plays, then stops
    - user clicks either one of the images (is actually clicking the click box on top of the image), and
    - then the slide start playing again and then eventually all the objects disappear (timing on the slide is about 17 seconds).
    How do I get all the objects to just stay on the slide, until the user clicks the next button on the skin?  I had thought the Next button would do that, but it's not (and I don't want a next button on there anyway).
    Thanks!
    Kelly

    Hi Kelly
    It's all in the timing.
    Can you share your project? If we can see it first hand, we can then offer suggestions about what you need to do.
    Cheers... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

  • How to prevent popup dialog from closing when commandbutton clicked

    Hi,
    I have a af:commandButton inside a popup dialog and the button action calls a method in backing bean. When this button is clicked I would like to run the method in backing bean and return control to the popup window. The method seem to run fine but the popup dialog closes automatically. Is there a way to prevent popup dialog from closing for this action?
    Thank you
    Kevin

    Hi Frank,
    Thanks for the link. I am not sure how to use this in my case. Following is part of what I am trying
    <af:popup ...>
    <af:dialog>
    <af:form usesUpload="true">
    <af:inputFile ..../>
    <af:commandButton text="upload" action="#{backingbean.uploadAction}"/>
    <af:outputText value="#{backingbean.filename} was successfully uploaded"/>
    </af:form>
    </af:dialog>
    </af:popup>
    When user clicks upload button I want to display a message that the file was successfully uploaded and keep the popup window open. But what happens now is once the file upload completes, the popup window closes automatically. This file upload part is not a must, user could skip doing the upload and instead input some text in a text area below (not shown in the code above). User could also just click cancel and exit the popup any time, so there is no mandatory field that I could check before closing the popup. Is there something I could do for this?
    thanks
    Edited by: user10720929 on Dec 23, 2008 10:36 PM

  • How to prevent multiple users from updating the same data in coherence

    Hi,
    I have a Java Web Application and for data cache am using coherence 3.5. The same data maybe shared by multiple users which maybe in hundreds. Now how do I prevent multiple users from updating the same data in coherence i.e. is there something in coherence that will only allow one user a time to update. If one user is in a process of updating a data in coherence and some other user also tries to update then the second user should get an error.
    Thanks

    I have a question on the same line. How can I restrict someone from updating a cache value when I a process is already working on it. I tried locking the cache key but it does not stop other process to update it , it only does not allow other process to get lock on it.

Maybe you are looking for

  • Creating process to get current row id

    Hello, I need to create a process while submitting in the process I need to have a pl/sql to update the row in the database. When I put hard coded value it is working fine, however when I refer the current column (being selected), it doesn't fire the

  • GATP:  Unable to check ATP (in GATP)  when creating sales order in R/3

    Issue:  When doing ATP check (sales order)  in R/3, I am able to see only availability screen of R/3 and not APO ATP screen.  In other words ATP check is performed in R/3 and not in APO (GATP). Simulation ATP check in APO works fine. Environment:  AT

  • Acrobat, swiftwriter and sharepoint problems.

    Hi! I have been using swiftwriter for a while when I do changes to a pdf file on a sharepoint. And this have been working fine. But now I have 1500 pdf files and I am using several metadata to filter them. And now a error message appears when I try t

  • Losing Formatting

    When I sync a text file to ipad, I lose formatting. I usually have to click a button that say I can read this but append here, and then I get something I can edit, but the formatting is gone. Then when I sync back to my main computer for finalization

  • HOW to make NI6537 work in 2.5V voltage level

    HI ALL, I just check on datasheet of NI6537, it shows this card work in 2.5V 3.3V kinds of voltage levels for digitial output. But the default setup is 3.3V. So how can we set it to 2.5V (in digital output)  (using C++). I once got one function: int3