Flash CS3 Play/Stop audio button problem

I made a play/stop audio button with this youtube tutorial (youtube.com/watch?v=XU6oMEFUFF8) but after the sound is finished I want the play button to show up agian.
Here is the actionscript:
import flash.events.MouseEvent;
play_btn.addEventListener(MouseEvent.CLICK,clickha ndler);
stop_btn.addEventListener(MouseEvent.CLICK,clickha ndler);
function clickhandler(event:MouseEvent):void{
swapChildren(play_btn,stop_btn);
what code should I add to my current code?
I also can send you the Fla.

You should consider using the Sound class. Here's a quick overview of it:
http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7d21.html
You'll be able to add event listeners to the sound to know when it completes so you can execute more code, such as swapping the play and stop button. There is an example in that overview of listening for the SOUND_COMPLETE event (e.g. channel.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete);). It should contain everything you need.
A basic example of what you'll end up with (there's many ways to do it) might look something like this:
// just set up and wait for click
var isPlaying:Boolean = false;
var mySound:Sound = new MySoundInLibrary();
var myChannel:SoundChannel = new SoundChannel();
myChannel.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete);
// buttons
play_btn.addEventListener(MouseEvent.CLICK,clickhandler);
stop_btn.addEventListener(MouseEvent.CLICK,clickhandler);
function clickhandler(event:MouseEvent):void
          swapChildren(play_btn, stop_btn);
          if (isPlaying)
                    isPlaying = false;
                    myChannel.stop();
          else
                    isPlaying = true;
                    myChannel = mySound.play();
function onPlaybackComplete(e:Event):void
          isPlaying = false;
          swapChildren(play_btn, stop_btn);
The basic idea is keeping a flag if the audio is currently playing. If it isn't then assign the sound to a channel and play it while setting the flag (isPlaying) to true. If it's already playing, set the flag to false and stop playing the audio.
The swapChildren is run in the onPlaybackComplete() method so when the audio completes the play button is swapped back in front.
Rather than swapping the children I'd urge you to toggle the .visible property instead. It's easy to run commands in the wrong order and get desynched on depth.

Similar Messages

  • Adobe Photoshop CS3 has stopped working: A problem caused the program to stop working correctly.

    I recently purchased a new desktop computer and installed Adobe CS3 Master Edition on it and I get the following error:
    Adobe Photoshop CS3 has stopped working: A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available.
    Out of the entire suite of tools only Photoshop will not launch. The weird thing is i also had the same Adobe programs installed on my laptop and I have not made any installation updates to that machine and i am getting the same error. I have always installed the same software on my two home machines with no problem until now. Any help is appreciated.
    Thanks,
    Andy

    You'll probably going to have to uninstall, then re-install the application; but you need to provide a lot more information;
    BOILERPLATE TEXT:
    Note that this is boilerplate text.
    If you give complete and detailed information about your setup and the issue at hand,
    such as your platform (Mac or Win),
    exact versions of your OS, of Photoshop (not just "CS6", but something like CS6v.13.0.6) and of Bridge,
    your settings in Photoshop > Preference > Performance
    the type of file you were working on,
    machine specs, such as total installed RAM, scratch file HDs, total available HD space, video card specs, including total VRAM installed,
    what troubleshooting steps you have taken so far,
    what error message(s) you receive,
    if having issues opening raw files also the exact camera make and model that generated them,
    if you're having printing issues, indicate the exact make and model of your printer, paper size, image dimensions in pixels (so many pixels wide by so many pixels high). if going through a RIP, specify that too.
    etc.,
    someone may be able to help you (not necessarily this poster).
    a screen shot of your settings or of the image could be very helpful too.
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

  • Flash CS3 Animation and Audio not timed properly when packaged.

    I am trying to create a simulation with audio, mouse movement, mouse clicks and screen changes. When I play the movie in Flash, the animation and the audio are timed properly. However, when I package it, the animation falls behind the audio. I am using wavs for the audio - I've tried mp3s also.
    I have a screen displayed with a mouse. The audio and a highlight indicate the next step, then the mouse moves and clicks the desired area - with a audio mouse click. The first "click" sound is pretty close to where it is supposed to be, but as the movie plays, it begins to occur earlier and earlier. So much so, that the audio starts to begin prior to animation is complete later in the move. This is not a real long demonstration, only about 1100 frames, but I notice the problem around frame 180.
    Any suggestions?

    IE stinks. There's a huge performance difference when playing
    SWFs in
    Firefox and IE. We have seen SWFs reach 100fps in FF 3.0
    while the same SWF
    taps out at around 40fps in the latest IE browser. It's not
    Flash, it is the
    browser.
    Adobe Certified Expert
    www.keyframer.com
    www.mudbubble.com
    (if you want to email me, don't look)
    "AMK4" <[email protected]> wrote in message
    news:gfk9ls$6kf$[email protected]..
    > This has me baffled to no end. I have a flash file
    that's behaving rather
    > odd.
    > Even the original author doesn't have an answer. I work
    on a WinXP system,
    > if
    > that matters. When I test the movie within Flash CS3, it
    works as
    > expected: the
    > animations ends as the audio fades out. When I publish
    it, and I open it
    > up in
    > Firefox, it works as expected. But that's where it ends.
    On the same
    > machine,
    > if I view it in Internet Explorer, the animation takes
    longer - it plays
    > slower. Consequently the audio ends before the animation
    is done.
    >
    > I've tried multiple WinXP machines, they all do the same
    thing. In Firefox
    > it
    > works as expected and the same way as previewed within
    Flash CS3. But,
    > viewing
    > it in IE, and the animation plays longer.
    >
    > Wanna see it for yourself? Look at the original author's
    page:
    >
    http://www.flashmo.com/preview/flashmo_137_intro/
    >
    > Open it up in IE and Firefox, side by side if you can.
    Does it play
    > correctly
    > in both (animation ends as the music fades) ?
    >
    > Suggestions anyone?
    >

  • Sat P10 Digital Audio/Buttons Problem.

    My new Toshiba (Sat P10-873) laptop has buttons on the front of it for playing digital audio and CD's. I use the mode button to switch between audio CD and the music CD, the problem being then when I switch to digital audio, it opens up media player and plays the default "David Byrne" track, rather than my playlist. According to the manual it should play the last opoened playlist but this for some reason does not work. Every time i close media player and then press the play button, it loads media player and begins playing David Byrne. Any suggestions on how I could fix this? Do i have to put my playlist in a certain location? or the audio itself? Do I need to set an option some where? Thanks.

    Well, I had only had the PC about half an hour at the time i was trying to do this so obviously no updates and no changes made at this time to the system.
    I have however solved the problem myself so just incase anybody else needs to know:
    The answer really was rather simple, for some reason, media player was saving my playlists under the "My Documents" folder of "Owner" rather than in my "My Documents" folder. I copied the playlist file from there and into my "My Music" folder and voila, everytime I switch to digital mode, it loads my playlist. Hope that made sense. Thanks for the help.

  • S12 Windows 7 Install -- Audio Button problems (Kalvin Klein?)

    Received my s12 a little over a week ago, and after adding another gig of ram, I decided to install W7 just to see how it would run.
    Long story short, it ran very satisfactory after some tweaking, and I decided to go with the solo install, and just ditched xp altogether.
    Everything works just fine, however the audio buttons don't work.....neither the hard buttons, or using the Fn + left/right arrows
    I could swear that it worked properly for the first day, but I must be mistaken.
    What's strange is that when attempting to use, I will get the OSD popup, indicating that it's muted, or when attempting to adjust up and down, it will only move down one notch (from 100%), however doesn't actually change the volume.
    I ran into Kalvin Klein's post about the realtek drivers, and after much slow downloading from the lenovo site, I installed them (178mb audio drivers is borderline ridiculous lol)
    sadly the situation is the same, and I was hoping that I'm just missing something stupid, or there is something I may be able to do.
    I don't particularly care, but it's nice to be able to quickly turn the volume down or mute it if I'm somewhere that doesn't care for loud sounds abruptly coming out of my comp.
    Suggestions?  Or am I just out of luck for the time being?
    Solved!
    Go to Solution.

    Hi welcome...
    if this Lenovo Energy Management Driver  (Includes the OSD) didnt work properly the official for S10-2 W7...
    EM Vs. 4.3.1.0 http://consumersupport.lenovo.com/en/DriversDownloads/drivers_show_1837.html
    try this Lenovo Energy Management Driver Version that i used a half year since beta.RC ...
    install this as admin and vista compatible...(origin from ideapad Y330
    http://consumersupport.lenovo.com/en/DriversDownloads/drivers_show_305.html
    regards KK
    Thinkies 2x X200s/X301 8GB 256GB SSD @ Win 7 64
    Ideas Centre A520 ,Yoga 2 256GB SSD,Yoga 2 tablet @ Win 8.1

  • Adobe flash CS3 professional trial version installation problem

    hi,
    I am trying to install the adobe flash CS3 professional
    trial version on windows installed and it complains that "internet
    explorer"
    is opened. I killed all the processes "iexplore.exe" , it
    still complains the same thing. Please let me know...am i missing
    something?

    Direct Download Links for Adobe Software
    Mylenium

  • Flash videos playing with audio echo on initial load.

    I have been having issues playing Flash videos in the current version of Firefox (10.0) as well as the previous version (unknown) over the past few months.
    When I open a page with a video it will begin playing with an echo as if two videos are playing at the same time with a slight delay on the second video causing an audio echo effect. So basically one video with echoing audio. The websites that I experience this the most are yahoo sports (happens practically every time) and gamespot (happens occasionally). If I refresh the page the echoing effect goes away.
    I am running Windows 7 64-bit.
    I have updated video drivers on my ATI Radeon HD 5800 series.
    My flash player / shockwave is 11,1,102,55 (updated) but I know I have experienced the same problem with previous versions.
    I have the following plug-ins enabled:
    1. Adobe Acrobat 10.1.2.45
    2. Current version of Ad-Block
    3. Divx Plus Web Player 2.2.0.52
    4. Divx VOD Helper Plug-In 1.1.0.6
    5. Microsoft Windows Media Player Firefox Plug-In 1.0.0.8
    6. Quicktime Plug-In 7.7.1 / 7.7.1.0
    7. Real Player 32 Bit Plug-Ins (4 total plug ins) 15.0.0.198
    8. Veetle Plug-Ins (3 total plug ins) 0.9.17.0
    I have some others as well but I thought these were the only relevant ones.
    Can anyone help me with my problem?

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • [JS CS3/4] Stop closing process problem (onEvent)

    Hi,
    I try to stop a closing operation through an event listener.
    I used that :
    #targetengine session
    docEvt();
    function docEvt()
        var myEventListener = app.eventListeners.add("beforeClose",myAddDocGlobalEvt, false);
    function myAddDocGlobalEvt(myEvent)
        myEvent.stopPropagation();
        myEvent.preventDefault();
        alert('stop');
    However, when I close the document...it's closed :-(
    I get the 'stop' alert but the document window is no longer visible.
    I would like to really stop the closing process. What do I do wrong ?
    TIA Loic

    Hi Loic,
    Is beforeClose cancelable?
    Try:
    alert(myEvent.cancelable);
    If false, you can't prevent default behavior.
    @+
    Marc

  • Captivate Audio Play/Stop Buttons

    I am new to Captivate 3.
    I need to play an audio file with full control
    (play/stop/pause buttons) on the slide.
    I know how to add an audio file to the slide or object. I
    also know how to stop the audio from playing via the "Stop slide
    audio when clicked" option for a button. But, I do not know how to
    start or pause the audio from a button.
    Basically, I needing the audio playback controls similar to
    those found in Flash.
    I also need a button to disable audio altogether.
    Any help will be appreciated.

    Rick, thanks for the suggestion but I'm afraid it didn't
    work. If by 'output folder' you mean the folder that is generated
    and contains the swf from Captivate then , yes I put the mp3player
    swf in there as well but it still does not appear on the published
    lesson. The weird thing is I inserted an image and put it 'behind'
    the mp3player.swf. The image appears alright but no sign of the
    swf.
    I had an alternative idea of putting the audio file in a flv
    and inserting this into the lesson. The flv option in captivate
    allows a 'player bar' to control the video embedded in the lesson
    but it seems like a lot of work and extra kbs' just to play an
    audio file.

  • Flash CS3 timeline display problems

    I have just upgraded to Flash CS3 and immediately noticed a
    problem when viewing and working with the Timeline window. When I
    click on a frame (keyframe or other) it highlights that frame
    completely white, which means I can no longer tell what type of
    frame it is. The same happens if I highlight a series of frames,
    they are all white and hard to interact with. If I highlight a
    series of frames and attempt to Right-Click, I can rarely get a
    sub-menu to show for quick options like 'Remove Frames' and 'Create
    Motion Tween'. Most of the time my Right-Click is ignored
    completely (ie nothing happens).
    I have searched Google, Flashkit and Adobe site for help with
    this, but no love. Has anyone else experienced this problem? The
    rest of my CS3 install is working perfectly.
    Computer: 20" iMac Intel 2.16Ghz Core 2 Duo, 2Gb RAM, 250Gb
    HDD (~100Gb Free)
    OS: Mac OS X 10.4.9
    Version: Adobe Flash CS3 Version 9.0

    quote:
    Originally posted by:
    sczulu
    Since upgrading from Flash V8, I'm having an issue where
    prominent fonts (such as Myriad Pro) appear jaggy until the file is
    published, making layout and design difficult. I've checked the
    text display settings with now change in appearance. The files do
    publish with anti-aliased text.
    I've noticed this issue as well and was wondering why I was
    having a problem, thanks for answering that question.

  • Problem with AIR Flash CS3 Italian version

    I have installed the Adobe AIR update for Flash CS3 italian
    mac version but in the welcome screen I don't see the Flash File
    (Adobe AIR) preset.I know about the fix that consists in deleting
    the folder HD:/Users/<username>/Libraries/Application
    Support/Adobe/Flash CS3/<language>/Configuration/StartPage
    and I did it, but the problem remains. Now what should I do?

    Hi Alessandro,
    Please try rerunning the Adobe AIR Update for Flash CS3 to
    see if the problem can be solved.
    If after running the updater again and it still doesn't work,
    the workaround is to create a Flash 9 (ActionScript 3.0) fla. Then
    selecting Commands > AIR - Application and Installer Settings
    and Flash will ask if you want convert the publish settings to
    Adobe AIR, click yes.
    Thanks,
    San

  • Can Flash CS3 open Flash 7.0 or 8.0 template?

    One of our departments is looking to purchase a Flash
    template which instructs you to have Flash 7.0 or 8.0 to edit. Just
    wondering if it will be editable in Flash CS3.
    Thanks

    blondy wrote:
    > One of our departments is looking to purchase a Flash
    template which instructs you to have Flash 7.0 or 8.0 to edit. Just
    wondering if it will be editable in Flash CS3.
    >
    > Thanks
    Yes, no problem.
    Best Regards
    Urami
    "Never play Leap-Frog with a Unicorn."
    <urami>
    If you want to mail me - DO NOT LAUGH AT MY ADDRESS
    </urami>

  • [Flash CS3] Resolution Issues

    Hello, I've been trying to piece together a FLA for the past few days now, only to encounter problem after problem. I've managed to overcome all but one problem I have been experiencing in Adobe Flash CS3 Professional, being a resolution problem.
    I've drawn 796 frames for a flash animation in Photoshop CS3 Professional using a graphics (drawing) tablet, saving them as a .JPG. Would have been smarter to use .PNG, but wasen't thinking straight at the time. After importing the files into the library 100 at a time to prevent a crash, I adjust the flash window to be 1176x894, two pixels short both width and height wise when compared to the files I will be using for the animation. This is to get rid of a tiny white line, as the files don't drop perfectly onto the flash even if they are the exact same resolution. So I plop on the cover for the animation, hitting F6 nine times to make nine extra frames for the intro. F7 for a new, blank keyframe, drop on the first (second really) frame of the animation itself...and it's not the same size.
    Note that both the cover and all frames are the exact same resolution, 1178x896 with the flash being 1176x894. It shrinks anything that isn't the cover, also a .JPG, by about 65% the normal size. There appears to be no way to adjust the frames, so down goes the flash unless I really want to make it much smaller. If anyone knows a solution to this problem, I would MUCH apperciate it. :-)

    Okay the most important lesson here is that when you are doing something like this test a few before you do all of them.
    Well I have no idea. I was going to say that you probably saved the jpegs at a different resolution. Flash expects 72 dpi. Of course that is possible that you have different resolutions.
    Also I've never had a problem where the pixel dimensions aren't what they are supposed to be. So you probably have something else going on here....

  • "Program" CS3 has stopped working"-Has anybody had this issue before?

    When I launch any of my Adobe CS3 software, I get a message as follows:
    "Adobe Photoshop CS3 has stopped working
    A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available."
    I tried resetting preferences, restoring my system to an earlier date, removing and reinstalling the software, and nothing has helped.
    I am running Windows Vista Home Premium.
    It is a licensed version of CS3.
    Please help. I am dead in the water here.

    Hi,
    Have you updated CS3?
    Go to help/Updates
    Try to run it in Administration mode
    Phillip

  • Flash CS3 Crashes on New File

    Adobe's Flash CS3 installs fine with no problems, and the
    program runs (ie: It opens up without any visible problems.) But
    when I go to try and create a new file to begin a project the
    program crashes. The error window reads:
    Flash.exe Application Error -- The instruction at
    "0x042c6b6d" referenced memory at "0x0000000d". The memory could
    not be "read".
    I've tried uninstalling the application and reinstalling it,
    but that didn't help either. I'm quite stumped and don't know what
    else to do. Any advice would be greatly appreciated.
    I also just tried to see if I could get by with using
    Macromedia Flash 8; and the same thing happens when I try to open a
    new file.
    Tips? Tricks? ... This is irritating. I need to get a working
    Flash program going for my Flash class ASAP.
    Thanks!

    In other news, all other Adobe products I use work just fine;
    but that's only Dreamweaver, Fireworks, Photoshop and Illustrator.
    It just seems to be Flash that is having problems. Does anyone know
    of any other programs that work like Flash and do pretty much the
    same thing? Make the same kind of files that Flash can open/edit?
    Has anyone else had the same issue I'm having? (In the first
    post.)

Maybe you are looking for

  • Why does iTunes keep crashing every time I open it?

    I did the shift+control move to put it on safe mode, and it launches fine when I do that. But, I can't sync my songs to my phone when I do that. Please help!

  • Mail version 6.3 (1503)

    I am running OS X 10.8.3 and using Mail 6.3 (1503) on a 2012 Mac Pro with 16 GB memory. The issue I am having is: All new mail shows up in the inbox as though they had been "Read" when I have not read them at all? The typical blue dot indicating new

  • Time dimension BPC10

    Tried to use Time dimension in one of the reports in BPC10NW. The expansion of Time dimension is following the alphabetical order. Example: If Q1 of a year is expanded, its showing up Feb, Jan, Mar. Same is the case with other Quarters(Q2/Q3/Q4). All

  • Parallels Desktop 3.0 crahes on start

    Hey guys, I bought Parallels 3.0 and installed it. But (nearly) every time I started (haven't installed XP-Partition, etc. yet) it it directly crashed, although I already have 2 GB RAM. Only times it worked was after restarts, but only 2 times. Below

  • Charges for Broadband - during fault

    Late December and into early january my broadband usage was excessive - diagnosed as faulty hub.  Fault resolved on 6th Jan when new hub installed.  I can't get suitable re-assurance via the many online chats and voice calls I have had with BT that I