Glitch in pause button code

Hello I'm a designer by trade & having difficulty getting my head around scripting. For most of what I'm doing, I'm managing to get by modifying snippetts that I've found online. However, one spot where I'm now stuck is making a pause button work for streaming mp3 files. I should qualify that adding the pause button was an after thought that I now realise is essential to the project working properly. The mp3 needs to start playing as soon as it starts downloading which is working fine. The mp3 needs to stop when the user goes to the next or the previous page, which is also working fine. But when the pause button is clicked first time, nothing happens. When it's clicked a second time, another instance of the mp3 starts playing. The pause and stop buttons work on this second instance, but not the first. I'm sure there's something really straight forward that I'm missing here, but I need a hand to find it. Following is the script as it now stands. Any help would be greatly appreciated.
import flash.media.Sound;
import flash.media.SoundLoaderContext;
import flash.net.URLRequest;
import flash.events.MouseEvent;
var s2:Sound = new Sound();
var req2:URLRequest = new URLRequest("intro2.mp3");
var context2:SoundLoaderContext = new SoundLoaderContext(8000, true);
var isPlaying:Boolean = new Boolean();
var pausePosition:Number = new Number();
s2.load(req2, context2);
s2.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
var soundchannels2:SoundChannel = s2.play();
//isplaying = true;
BackBut.addEventListener(MouseEvent.CLICK, f3_ClickToStopAllSounds);
controller.addEventListener(MouseEvent.MOUSE_DOWN, btnPressController, false, 0, true);
stop_btn.addEventListener(MouseEvent.MOUSE_DOWN, btnPressStop, false, 0, true);
function onComplete(evt:Event):void
//Play loaded sound
soundchannels2 = s2.play();
isPlaying = true;
function btnPressController(evt:MouseEvent):void
switch(isPlaying)
case true: controller.gotoAndStop(2);
pausePosition = soundchannels2.position;
soundchannels2.stop();
isPlaying = false; break;
case false: controller.gotoAndStop(1);
soundchannels2 = s2.play(pausePosition);
isPlaying = true; break;
function btnPressStop(evt:MouseEvent):void
{ pausePosition = 0;
soundchannels2.stop();
controller.gotoAndStop(2);
isPlaying = false;
function f3_ClickToStopAllSounds(event:MouseEvent):void
SoundMixer.stopAll();
soundchannels2.addEventListener(Event.SOUND_COMPLE TE, s2Complete);
function s2Complete(e:Event)
this.nextFrame();
stop();
BackBut.addEventListener(MouseEvent.CLICK, goback);
function goback(event:MouseEvent):void
prevFrame();
stop();

Problem solved!!
After much experimentation, I tried changing "switch(isPlaying)" to "switch(!isPlaying)" & much to my surprise (and great relief) it worked!

Similar Messages

  • Removing client's ability to use play/pause button

    Hi all
    I am keen to use Presenter to put together a language listening test for some clients. My clients want their students to not be able to pause the presentation so, say, they can't pause, translate word, pause, translate word and so on. In order to do this, I need to remove or lock the Pause/Play button that appears in the skin of a Presenter module.
    I realise I can completely remove the Player bar by opening up the vconfig.xml file and changing the value next to <uishow name="playbar"> to false. This is a quick and dirty solution and may do the trick. However, I would like the students to still be able to see the time count down for each slide in the player bar. Why? Well, because my clients want their students to listen to an audio track, receive one minute's thinking time and then go on to answer a question about the track. The students should know how much time they still have available. This means somehow either removing the Play/Pause button or at least locking down its functionality.
    I'm not a Flash wiz (though I do have it) but I don't mind making changes to a few codes here and there. I just need to know which file/s and which code.
    Your thoughts/expertise would be greatly appreciated. Thanks in advance
    Peta

    Hi Peta,
    You're right...you could hide the playbar by setting that value to "false", but as you have no doubt already seen, that modification eliminates everything, which won't totally solve your problem.
    Since you have Flash, I'd recommend that you create a simple .swf file that will ultimately hide the Play/Pause button in the playbar area of Presenter content.  I'll be honest...I haven't "locked" the Play button, but that might be something to investigate IF what I'm proposing here doesn't do the trick for you.
    So here we go....
    In Flash, create a small stage area and on frame one in your timeline add the following:
    this.onEnterFrame = function () {
    _root.m_controlBar.m_playBtn._visible= 0;
    Save the Flash file as "playBtnKill.fla" and then publish it.  Then head back to PowerPoint and add the swf to the first slide in a presentation using Presenter's Import Flash function.  Publish the content and the Play button should be gone!
    Programming NOTE: because Presenter is set up for Flash Player 6/7/8, its best to code everything using Flash Player 6 / Actionscript 2.0 as the coding environment.
    A couple of things to keep in mind about this:
    First, by placing the swf file on the first slide of your PPT deck, the Play button will be affected for the entire duration of your presentation.  If you need it to show / hide / show /hide periodically throughout the deck, then you might want to think about how you want to handle the overall stucture of your course.  Meaning, that what might work is to kill off the Play button entirely, but use a PowerPoint graphic (that looks like a Play button) and then time that object to appear after a certain amount of time.  Of course, then you'd have to hyperlink the PPT object to the next slide in your deck so that folks will be given an opportunity to advance to the next slide.
    Second, since your intention is to remove the Play button, you should probably leave the "Advance by user" feature set to "NO", otherwise you will ahve to provide some mechanism of navigating from slide to slide (as mentioned above).  At least this way, by the time you've reached the end of the audio for a slide, the presentation will automatically advance.
    Hope that helps!
    Rob
    http://www.robrode.com/yabb/

  • When I pause my code, the case where execution is happening does not pop up.

    I have a queue driven state machine and when I press the pause button LabVIEW does not switch to the case where the execution is paused. Is there any easy way to find where the execution has paused without stepping through each case?

    The probe on the dequeued command should be helpful though, when the code is running normally the indicator will be flickering away showing the cycle of states the code is going through, if the code gets stuck it will stop cycling.
    Another approach might be to (temporarily) put an indicator on the dequeued command, and create a seperate execution loop in the VI that monitors the dequeued command, or some other parameter that's a good indication the code is cycling normally. If this watchdog loop sees that the main loop stop, it calls a case in a case structure that contains a breakpoint. This pops open the diagram, so you can see what's up.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Play & Pause buttons work...but not with each other

    V!P and dzedwards were a big help to me yesterday but now
    I've come up against something else...
    I've got 3 music buttons on a page. The code that I have
    plays and pauses each button perfectly. But if I have Button 1
    playing and I click on button 2 (without stopping button 1
    manually), and button 1 is still playing...both play at the same
    time. Which, I understand why it's doing that but I'm not sure how
    to fix it.
    What do I need to add to the code so as to stop the first one
    from playing if I don't manually click it to stop? The first
    button's instance is monkey7, the second button's instance is
    iBelieve and the third button's instance is Perfection.
    monkey7 = new Sound();
    monkey7.attachSound("monkey7.mp3");
    monkey7.start(0);
    var elapsedTime:Number;
    var played:Boolean = false;
    pauseButton.onRelease = function() {
    if (played) {
    monkey7.start(monkey7.position/1000);
    played = false;
    } else {
    monkey7.stop();
    played = true;
    Thanks. And I apologize to V!P and DZ in advance.

    Well..not exactly. Crap, how do I explain this? The
    pauseButton is where you're applying the stop commands but from
    what I can tell, it's not doing anything because the play/pause
    button (pauseButton) isn't the problem, it's the button for the
    next song.
    My problem is when they don't click the play/pause button and
    go directly to the next button with the next song.
    If it makes it easier to see what I'm talking about, you can
    go to
    http://www.monkeypunk.com/,
    click on the music button, click on Monkey #7 button and you'll see
    the layout. It takes a couple of seconds for the preloader to
    appear.
    The arrow button on the right of the songs is the
    pauseButton. My problem is, when they don't click that but click
    the next button beneath, the button previous to it continues to
    play.
    Again, I apologize if I didn't explain it better
    originally.

  • How to add a toggle play/pause button for a flash video

    Hi,
    Can someone help me with this flash video. I am creating a
    custom video controllers and I need to have a toggle play and pause
    button. How would do I go about that. I tried to use it on a play
    button and the video pauses and play, but I need to get the pause
    image and play image in there. So, can anyone give me the code for
    that . I really appreciate it.
    Thanks

    this is not truly an event driven state machine....
    too many loops
    data flow dependencies
    wrong use of boolean controls
    not a true state machine
    here is a template...
    Spoiler (Highlight to read)
    Attachments:
    event driven state machine.llb ‏27 KB

  • VI executable (.exe) without running, running continuously, abort execution and pause button

    Dear All,
    I want to make build an application (.exe) from a VI and I don´t want the front panel to show the running, running continuously, abort execution and pause buttons (VI Toolbar Buttons). The purpose is to make a SCADA application without the risk of accidental STOP.
    Maybe the question is too trivial but I am new to LabVIEW and I don´t find the way to do it (I unchecked the "Show Abort Button", from the VI properties menuo of the Build Specifications but nothing happens).
    Thank you very much
    Javier
    Solved!
    Go to Solution.

    Just hide the entire toolbar.
    LabVIEW Champion . Do more with less code and in less time .

  • Play/pause button AS2

    Have a Audio in timeline.
    Need to add AS2 code on the button to pause the audio when Pause Button is pressed.
    And need code for play button to play the audio when Play Button is pressed from the same point where it was paused.

    assign your sound's sync property to stream and your button to stop and play the timeline.

  • Stop and Pause Buttons and Estimated Execution Time

    I have more or less completed my programme (as attached).
    I am just left with two doubts - first: is it possible to let the user know the estimated time to finish executing the entire code/ running the entire experiment on my devices?
    I am currently trying to calculate this estimated time by using the arithmetic functions and time stamp. I tried putting on both the left and right sides of my case structure but it never runs - I tired running the code and after all other commands are executed, the estimated time is still not displayed. I suspect that even if the estimated time is displayed, it would only be displayed after all other commands are executed.
    I have tried looking up on timed structures but they don't seem to fit the job.
    Do you have any advice on this?
    Second: While loops could only be stopped (by pressing my 'STOP' button/Boolean that is linked to the loop condition) only after the first execution of the loop. How could I let my user stop the execution of code during the first run of the loop or should I wire my code differently using another structure?
    As for the 'Pause' button to pause the VI, I have read about the 'Wait for' function (http://zone.ni.com/reference/en-XX/help/371361H-01/glang/wait_for_front_panel_act/). I am not sure if this is the right function I am looking for and if this function enables the user to 'un-pause'/toggle the switch and enable the execution of the subsequent commands.
    This function seems useful but it does not solve the problem of the while loop having to execute at least once before I terminate it and it seems like this function acts like a 'Stop' function that exits the loop, terminating all commands instead of pausing the VI.
    What is your advice on this?
    Thank you so so much!

    Duplicate Post

  • How to hide only pause button on toolbar in run time

    hello,
    I had hide all the buttons like run, run continuous, abort vi and others by navigating to VI Properties and unchecking the corresponding options.
    when i run the vi, all becomes hide except pause button and i didn't find any option for hiding it manually as well as programatically.
    can any one tell me how to hide pause button. i have an urgent requirement for same.
    Thanks & Regards,
    Samriddh Sarbalhi
    Solved!
    Go to Solution.

    wprice wrote:
    I just found that the option called "Show Toolbar When Running" is located under VI Properties > Windows Appearance > Customize. I disabled it and it worked. Thanks!
    So, the option I mentioned is still available, but only at a different place.
    I was shocked on seeing your earlier reply, "There is no such option in LabVIEW 9.0 or higher.". 
    - Partha
    LabVIEW - Wires that catch bugs!

  • My ipod nano 6th generation does not start on pressing the sleep/pause button  or pressing both sound low and sleep pause button.it starts while connected to power it is fully charges

    i have an ipod nano 6th generation .version 1.2 yesterday i  restored it on i tunes  using my system window 7. for the last few days it does not start when the sleep/pause button is pressed.or even by pressing the both button sleep/pause and sound minus..It starts while connected to power. and then continues working. I can not put off it and it automatically goes off after some time its performance is ok  after starting by connecting to power and then disconnecting the cord.
    what would be the reason and what to do?>

    Call Apple Care as you are still under warranty.  

  • ITunes won't play song, even though pause button appears

    Recently my iTunes has stopped playing songs. If I click the play button, the pause button appears but the progress bar does not move and no sound is made. The volume on my computer is fine as I can still watch videos on youtube and such. I've recently updated to the lastest iTunes and am not sure whether the songs played find after that or not. I read that it could be a probably with quicktime but I've deleted that and downloaded it again but that did not help.
    Please help me!

    I noticed today I am having the same problem. Song would not play in Ver. 9.1.0 and 9.1.1. Same song plays fine in another media player. Also seeing the same that al0022 is seeing, my play button changes to a pause button, and my progress bar does not move. I am able to navigate around iTunes until I try to play a song then I have to kill the task.
    I had a Windows update performed yesterday, and believe the windows update is the cause of the problem.
    Anyone else unable to play after Windows updates were performed?
    Collin

  • 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

  • Add a play/pause button on old Macbook

    I got pretty used to have a play/pause button on my new iMac. But as I still have an old Macbook Pro (the first Intel core duo 2006 model) Apple didn't make buttons on the keyboard to navigate through your media in iTunes or Spotify or whatever media program is active.
    I'd like to add a play/pause functionality to my F11 and a forward functionality to my F12 button. I've managed to do so in system preferences > Application Shortcuts. But the thing is that the buttons only work if the program (I'm mainly using Spotify at the moment) is active. I want to make these buttons in all other programs (just like the play/pause buttons on new Macs). How can I do that?
    PS: I don't mind using terminal for this.

    Does anyone know if it's impossible?

  • Mini's Play/Pause Button

    Hello I was wondering if anyone else has had such an issue. It's not a major problem but it does bug me sometimes.
    I have a 2nd generation Ipod Mini that's still under warranty. I usually turn off my Ipod by pressing and holding down the play/pause button. Lately however, I've noticed that this doesn't always work. Somtimes I have to try a couple of times for the Ipod to recognize that I'm actually holding down that key for it to turn off and not just pressing it to enable pause or play mode. The problem isn't always consistent but this was definitely not an issue before.
    Now my question is, is it really worth it to send it back to Apple? I understand that all Mini's that they send back now are refurbished..but is it worse to get a refurbished one back? Also, my warranty is expiring in November. If I do send my current Ipod back and get another one back does my warranty still only go until November? What if something is wrong (or goes wrong) with the one that they send back after the November deadline? Am I screwed?
    Thanks for any answers!

    Don't keep postiong with nothing else to say...saying "anyone?" is not going to make us answer any faster.
    Try this:
    when you go to turn it off, don't touch any buttons for a couple seconds before hand. I seem to have the same problem with my nano and I think the problem is just that the processor can't keep up.
    I hope this helps!

  • 30GB Play/Pause button won't work.

    Yes, another iPod Classic's play/pause button is messed up. I got it in March '09 so I believe that's over the 90 day fixing range. I've tried resetting, holding the menu & center button, & all of the suggestions on the Mac site, but it still won't work.
    Any ideas what could be wrong & how to fix it?

    Besides resetting the iPod, have you attempted restoring it? You can do that by clicking the "Restore" button on the the iPod's Summary page in iTunes.
    Assuming that doesn't work, you can check your [warranty status|https://selfsolve.apple.com/GetWarranty.do] to see if you are still covered for hardware repair. I doubt any 30GB iPods are still under warranty, since they were discontinued over two years ago, but you said you got it in March 2009 - did you purchase it used?
    Whether it's under warranty or not, you can always make a Genius Bar appointment at your closest Apple Store and see if they have any other suggestions, free of charge. If it's a hardware problem, they can replace the iPod for you, but there would be a charge to do so if you're out of warranty.
    Shawn

Maybe you are looking for

  • PL/SQL web service: question about stub

    hello, I'm currently learning how to work with PL/SQL Web Services. I have a question about stubs. The point is, I can deploy a web service to the OC4J server and it works. It also works when I create a stub following the WSDL I made with creating th

  • Can photoshop CC open raw files from Lightroom 5?

    Trying to open raw files from Lightroom 5 in Photoshop CC 2014, with no luck. Anyone?

  • Built in isight - how to activate in chat rooms

    Hi. I'm a new MacbookPro user and am pretty new to using isight. It works in Yahoo ok. Mac version of MSN does not seem to have provision for webcam and I can't activate the camera in chat rooms with webcam facility. Any ideas?

  • MBP+WinXP won't connect to network. It sees the wireless network but stops.

    I've been fighting this for two solid days. Time Capsule takes an address automatically from my router/modem. The MacBook Pro connects wirelessly thru Time Capsule to my ethernet network and the internet. No problems. Windows XP on the same Mac wirel

  • IPhoto won't work with Mavericks??

    Hi, I just got mavericks on my used mid-2011 macbook air. iPhoto now has a white slash going through it saying I need to update it. The problem is that when I try to update it, the apple ID that it is connected to is the previous users. I have no pro