AS3 play and pause timeline as well as soundchannels

I am trying to make global playback control buttons to play & pause the timeline as well as the sound channels. I have managed to get the buttons to function correctly with  controlling the timeline but I need them to also work with the  soundchannels too.
Here is the code I created for the buttons:
btnStop.visible = true;
btnPlay.visible = false;
var movieclip:MovieClip;
function stopMovieClip(mc:MovieClip):void{
mc.stop();
for (var i:int = 0; i < mc.numChildren; i++)
var mcChild = mc.getChildAt(i);
if (mcChild is MovieClip) stopMovieClip(mcChild);
btnPlay.visible = true;
btnStop.visible = false;
function playMovieClip(mcPlaying:MovieClip):void{
mcPlaying.play();
for (var j:int = 0; j < mcPlaying.numChildren; j++)
var mcPlay = mcPlaying.getChildAt(j);
if (mcPlay is MovieClip) playMovieClip(mcPlay);
btnStop.visible = true;
btnPlay.visible = false;
btnStop.addEventListener(MouseEvent.CLICK, stopAll);
function stopAll(event:MouseEvent):void
stopMovieClip(con);
btnPlay.addEventListener(MouseEvent.CLICK, PlayMC);
function PlayMC(event:MouseEvent):void
playMovieClip(con);
And the code for the soundchannels:
import flash.media.SoundChannel;
var strokeVOSound:strokeVO = new strokeVO();
var strokeVOChannel:SoundChannel = new SoundChannel();
var bleedVOSound:bleedVO = new bleedVO();
var bleedVOChannel:SoundChannel = new SoundChannel();
yellow_mc.visible=false;
blue_mc.visible=false;
strokebtn_mc.addEventListener(MouseEvent.CLICK, displayStroke);
strokebtn_mc.buttonMode = true;
function displayStroke(e:MouseEvent):void {
trace ('Clicked')
yellow_mc.visible=true;
blue_mc.visible=false;
bleedVOChannel.stop();
strokeVOChannel = strokeVOSound.play();
bleedbtn_mc.addEventListener(MouseEvent.CLICK, displaybleed);
bleedbtn_mc.buttonMode = true;
function displaybleed(e:MouseEvent):void {
yellow_mc.visible=false;
blue_mc.visible=true;
trace ('Clicked')
strokeVOChannel.stop();
bleedVOChannel = bleedVOSound.play();
The soundchannels are triggered by a movieclip which acts as a button.
Any help would be much appreciated.
Thanks

For the two soundchannel sounds you have, you will need to keep track if and which one is playing so that you can use some logic to stop the sound right after you mark where the sound was (position)  so that you can resume playing it again when the play button is selected.
So if the stroke sound is started, you could assign a boolean variable named something like 'strokeplaying' to be true (setting the other sounds similar boolean false).  Then, in your pause function you would test to see if strokeplaying is true and if it is, store the position property and stop the channel playing. 
When play is selected, similarly, you test if that sound is true and if so you restart it using the position value you stored as the starting point.  You do the same for the other sound... remembering that it is possible neither is playing when pause it clicked.

Similar Messages

  • HTML5/quicktime player plays and pauses several times a second

    We've been getting some weird entries in our statistics logging on our streaming media system, and I've managed to not-so-much recreate the problem as be around when it occurs.
    Playing about with the interface (scrubbing quickly, then playing/pausing repeatedly, etc) doesn't seem to trigger the problem - it just seems to happen occasionally after a few minutes of a player being open in full-screen mode.
    The actual symptoms are the the stream suddenly starts pausing and playing incredibly quickly - upwards of 10 times a second - and you can see the play and pause buttons swapping incredibly quickly. We're not getting this problem with any other of our players, and we're using the iPad's built-in player, not our own HTML5 player, although I'm still not entirely convinced it isn't a bug with our servers.
    The stream also seems to start looping, and as soon as it reaches the end of the stream it starts again, which is making me wonder if it's a bug with the UI itself, as if the play and pause buttons are getting triggered constantly, but changing the rotation doesn't stop it happening. I also wondered if it was something silly, like someone sneezing on the screen and the moisture triggering the touch screen, but that doesn't seem to be the problem either.
    Has anyone else seen this behaviour before? I don't seem to be able to directly trigger it - it just seems to happen occasionally.
    I'm trying to get a video of the symptoms, but it's not playing ball at the moment. If I can get it to do it again, I'll add a video example in a later post/edit.

    We've been getting some weird entries in our statistics logging on our streaming media system, and I've managed to not-so-much recreate the problem as be around when it occurs.
    Playing about with the interface (scrubbing quickly, then playing/pausing repeatedly, etc) doesn't seem to trigger the problem - it just seems to happen occasionally after a few minutes of a player being open in full-screen mode.
    The actual symptoms are the the stream suddenly starts pausing and playing incredibly quickly - upwards of 10 times a second - and you can see the play and pause buttons swapping incredibly quickly. We're not getting this problem with any other of our players, and we're using the iPad's built-in player, not our own HTML5 player, although I'm still not entirely convinced it isn't a bug with our servers.
    The stream also seems to start looping, and as soon as it reaches the end of the stream it starts again, which is making me wonder if it's a bug with the UI itself, as if the play and pause buttons are getting triggered constantly, but changing the rotation doesn't stop it happening. I also wondered if it was something silly, like someone sneezing on the screen and the moisture triggering the touch screen, but that doesn't seem to be the problem either.
    Has anyone else seen this behaviour before? I don't seem to be able to directly trigger it - it just seems to happen occasionally.
    I'm trying to get a video of the symptoms, but it's not playing ball at the moment. If I can get it to do it again, I'll add a video example in a later post/edit.

  • [svn:osmf:] 10017: Adding a style sheet, adding a backdrop to the examples list, adding icons to play and pause icons.

    Revision: 10017
    Author:   [email protected]
    Date:     2009-09-04 06:43:44 -0700 (Fri, 04 Sep 2009)
    Log Message:
    Adding a style sheet, adding a backdrop to the examples list, adding icons to play and pause icons. Setting theme color to red.
    Modified Paths:
        osmf/trunk/apps/samples/framework/ExamplePlayer/ExamplePlayer.mxml
        osmf/trunk/apps/samples/framework/ExamplePlayer/org/openvideoplayer/view/MainWindowLayout .mxml
    Added Paths:
        osmf/trunk/apps/samples/framework/ExamplePlayer/assets/
        osmf/trunk/apps/samples/framework/ExamplePlayer/assets/ExamplePlayer.css
        osmf/trunk/apps/samples/framework/ExamplePlayer/assets/assets.swf

    Revision: 10017
    Author:   [email protected]
    Date:     2009-09-04 06:43:44 -0700 (Fri, 04 Sep 2009)
    Log Message:
    Adding a style sheet, adding a backdrop to the examples list, adding icons to play and pause icons. Setting theme color to red.
    Modified Paths:
        osmf/trunk/apps/samples/framework/ExamplePlayer/ExamplePlayer.mxml
        osmf/trunk/apps/samples/framework/ExamplePlayer/org/openvideoplayer/view/MainWindowLayout .mxml
    Added Paths:
        osmf/trunk/apps/samples/framework/ExamplePlayer/assets/
        osmf/trunk/apps/samples/framework/ExamplePlayer/assets/ExamplePlayer.css
        osmf/trunk/apps/samples/framework/ExamplePlayer/assets/assets.swf

  • Sometimes my play and pause button(F8) is not working.

    I don't know why, sometimes the button of play and pause button is not working why?
    do you have any advice or do you think is broken??

    Try resetting the PRAM (if you are able to do so).
    Otherwise, I would take it in for diagnosis.
    Barry

  • The music app on my Iphone 5 is acting up, it keeps skipping  songs and wont allow the to play. You can see the music icon the on notification bar play and pause. When i go back to the app is states the url is not responding. I have restored it.

    The music app on my Iphone 5 is acting up, it keeps skipping  songs and wont allow the to play. You can see the music icon the on notification bar play and pause. When i go back to the app is states the url is not responding. I have restored it from the backed up cloud save. It is the music app, I played music on pandora and it worked fine. I think it must be the app or the ios.

    restore with itunes not from an itunes backup or cloud save they do absolutely nothing only a clean restore will solve your problem

  • Play and Pause button

    Hello,
    Because my playbar is disabled due to my pretest within my file I dont have a play and pause button.
    i have created 2 buttons. One to pause the program and the other to play.
    The problem is, once I click on the pause button, then on the play, then on the pause again - the pause button is disabled. in other words, i am only ever able to click on either one of the buttons once.
    I have the 'infinite' button checked but i am still not sure why its not working.
    -Stephanie

    Hi Stephanie,
    You didn't tell how you trigger pause/play with those 'buttons' - since you are on CP6 or later, use shape buttons that can be put on the master slides or timed for the rest of the project.
    http://blog.lilybiri.com/why-i-like-shape-buttons-captivate-6
    http://blog.lilybiri.com/toggle-shape-buttons
    If you use a simple action (using the Action accordion), another possibility besides the excellent event-handler widget (only for SWF-output) is to replace it by a standard action: http://blog.lilybiri.com/why-choose-standard-over-simple-action
    Lilybiri

  • The play and pause buttons in control center

    the play and pause buttons in control center some times work and some times not !!!
    any solution please ? !

    Hi m-tillawy,
    Thanks for using Apple Support Communities.  I would try a restart/reset of the iPhone:
    iPhone, iPad, iPod touch: Turning off and on (restarting) and resetting
    http://support.apple.com/kb/HT1430
    If the issue persists after that, I would attempt a reset of all settings as per this article:
    Reset iPhone Settings - iPhone User Guide
    http://help.apple.com/iphone/7/#/iph7a2a9399b
    Reset iPhone settings
    Reset iPhone settings. Go to Settings > General > Reset, then choose an option:Reset All Settings:  All your preferences and settings are reset.
    Cheers,
    - Ari

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

  • Play and pause button and control bar are missing below xfinity player

    when I want to watch a video noticed play and pause button and control bar are missing below xfinity player.

    For the two soundchannel sounds you have, you will need to keep track if and which one is playing so that you can use some logic to stop the sound right after you mark where the sound was (position)  so that you can resume playing it again when the play button is selected.
    So if the stroke sound is started, you could assign a boolean variable named something like 'strokeplaying' to be true (setting the other sounds similar boolean false).  Then, in your pause function you would test to see if strokeplaying is true and if it is, store the position property and stop the channel playing. 
    When play is selected, similarly, you test if that sound is true and if so you restart it using the position value you stored as the starting point.  You do the same for the other sound... remembering that it is possible neither is playing when pause it clicked.

  • Premiere CC crash while playing and zooming timeline

    Regularly crashing Premiere CC now while playing back the timeline, I zoom in and out on the timeline using my +/- hot keys and Premiere CC will crash.  I hate to say it but Premiere is starting to become unstable like my prior copy of Sony Vegas Pro.  It's frustrating.

    It's a generic error so unfortunately, it doesn't say much.
    "Adobe Premiere Pro CC 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 click 'Close program' and Premiere CC goes away. For my setup, ti's pretty easy to replicate:
    1. Open sequence. Starting playing.
    2. While it's playing, click somewhere on the timeline and start zooming in/out with +/- keys.  The crash will occur shortly afterwards.

  • My apple wireless keyboard is not responding on all the buttons starting from esc up to the play and pause button,please can u help me on how to solve this problem

    The mission control,launchpad ,two brightness button,reverse &amp; play &amp; pause button are not working on my apple wireless keyboard,please help me

    Try resetting the PRAM (if you are able to do so).
    Otherwise, I would take it in for diagnosis.
    Barry

  • Color shift between play and pause

    Hello,
    On CC 7.0 and 7.1, I noticed there is an important color shift between pausing and playing my timeline when using "CineForm Visually Perfect" encoded source material.
    This is especially noticeable on reds.
    Using other codecs, there is no such shift.
    My video card is a Geforce 650M. At first, I thaught it might be related to the video overlay settings of the card, but there are no such settings in the control panel.
    Besides, using Quicktime to play the source produces no shift as well.
    As I am often doing color correction using Premiere, and as I have dropped Avid exactly because I always had this same problem (when using a profiled calibrated screen), I would like to know precisely what is going on. As I'm regularly producing shows for broadcast, it is a real problem not to be sure whether what you see matches the final exported output in all circumstances.
    NB : For the need of searching the cause of this problem I disabled any custom profiling of my screen.
    Thanks ! for any answers.
    Fred

    Sure and thanks. But nevertheless, if you color correct using a calibrated screen, and produce for the web ; or if you do a first pass of color correction before the ultimate pass happens with a "properly calibrated TV", wouldn't you like that your paused frame would look like your playing frame ?

  • Vectorscope difference between play and paused

    Hello there,
    I'm new to Speedgrade, when I see the vectorscope the levels of the colors are different when the video is paused compared to when the video is played.
    since I'm trying to have safe values for broadcast, which one do I follow, the video paused or the video playing?
    thanks!
    Luc

    There are settings in the Preference panel (the wrench icon) for whether the scopes update during playback or only during pause/stop, as running them during playback does use significantly more horsepower while the playback is ragging your hardware out. Most folks leave the updating for "pause" in order to assure the smoothest playback. Some folks also have AMAZING systems and can run 6k with scopes on with full-rez playback without a hitch. Right.
    Well, for the rest of us, update during pause is a wiser choice. Those figures/shapes will be accurate. Most clips tend to have a similar range through the clip ... if you've got a spot that suddenly jumps way high or low from the other parts of the same clip, well ... you might realistically need to sub-clip that bit and grade it by itself, rather than trying to mush everything into "legal".
    Of course, there is also the effect available in primaries of "Legalize ... " ... which some folks love, and others say NEVER use. If used, it's a top-layer thing. As with Adobe programs, the lower layers feed "up" to the top layer, if you put it below other things they can change the total values.
    Neil

  • IPhone keeps playing and pausing on its own unless its locked!?

    Hello everyone.
    I have had a host of problems with my iPhone since I got it, but this is just one I can't ignore any longer. It just starts playing music, randomly, without prompt or instruction. Then it pauses from time to time. If I'm playing music without the phone being locked, it frequently pauses for a time, then starts again randomly.
    Has anyone else experienced this problem before? Any suggestions?
    The second problem, and this is one I've literally just started experiencing, is that it keeps fast-forwarding/skipping THROUGH songs - I don't mean jumping from one song to the next, but actually jumping about twenty seconds or so through the song, for a bout a second, then continuing to so until the song is over. Has anyone else experienced this? I'd like to think it's bad files, but this isn't the case - songs I've bought off iTunes are doing it as well, for no good reason. And this began minutes after I had just backed-up and restored and updated my phone. I'm clueless! And frustrated...
    Please somebody help!

    is this happening while you have the headphones plugged in? if so, you have either a bad set of headphones or a bad headset jack. the headphones can be replaced at the apple store or through the web (sorry, but i can't find the link i used to do it a few months ago). a bad headset jack probably has to be fixed by replacing the phone at an apple store. you might be able to do the headset replacement by calling apple.

  • My iphone 4 keeps switching songs, playing and pausing by itself especially when I use my headphones

    Ever since I installed the iOS 7.1 update, my iPhone 4 keeps playing, pausing, switching to the next song, fast forwarding by itself. Especially when I use my headphones. It's getting really frustrating because not only is it when I listen to the music player, but also on youtube videos and then it pause the video and then play the music from the music player or it would pause music on soundcloud by itself too. This mostly happens when I use my headphones but when I don't use my headphones I don't see it happening.
    A friend called me and I was using my headphones and the conversation kept getting hanged up by itself it wasn't until I stopped using the headphones that I could have a normal converstation, but I only talked for less than a minute without the headphones so it wasn't enough to tell me that it is the headphones that is the problem. So is it my phone or my headphones? Is this a software problem because of the update because my headphones were not doing this before, HOW CAN I MAKE THIS STOP. (This has been happening for almost a week now)
    BTW: I also noticed that if I am listening to music on the music player or youtube and its in my pocket or hand and Im jumping to the song or shaking (lol) the songs pause and plays then switches to the next song aaaaurrrrrruuuuuuuggggggghrrrrrghhhhhhh WHATS GOING ON

    Hello alplease,
    It sounds like your touch screen is acting erratically and seems to be exacerbated when you have your earphones in. I recommend the information in the following article named:
    iPhone, iPad, iPod touch: Troubleshooting touchscreen response
    http://support.apple.com/kb/ts1827
    Restart your device
    Hold the On/Off button until "slide to power off" appears. Slide to power off your device. When it is off, press the On/Off button to turn it back on.
    If you can't restart your device, reset it by pressing and holding the Sleep/Wake button and the Home button at the same time for a least ten seconds, until the Apple logo appears.
    Clean the screen with a soft, slightly damp, lint-free cloth.
    Avoid using the device while wearing gloves, with wet hands, or immediately after applying hand lotion.
    If you have a protective case, or if you are using a plastic sheet or film on the display, try removing them and testing the device without it.
    If the steps above don't resolve your issue, please schedule a service appointment with an Apple Retail Store for evaluation. If an Apple Retail store is not an option, contact Apple to find out your best service option or see theService FAQ for your product.
    You can also try closing all the open apps:
    iOS: Force an app to close
    http://support.apple.com/kb/ht5137
    Double-click the Home button.
    Swipe left or right until you have located the app you wish to close.
    Swipe the app up to close it.
    When you have done that and restart the phone and test the issue again:
    iOS: Turning off and on (restarting) and resetting
    http://support.apple.com/kb/ht1430
    Thank you for using Apple Support Communities.
    Regards,
    Sterling

Maybe you are looking for