AS3 sound pause/play buttons not working

I have three buttons:play_btn, pause_btn; and stop_btn within a movie clip labeled controller.
I can't make the play button start where the pause button is left. Everytime, the sounds starts from the beginning.
Please help!
var mySoundReq65:URLRequest = new URLRequest("sounds/pronouns.mp3");
var mySound65:Sound = new Sound();
var mySoundChannel65:SoundChannel = new SoundChannel();
var lastPosition:uint= 0;
var isPlaying:Boolean = new Boolean();
var isPaused:Boolean= new Boolean();
mySound65.load(mySoundReq65);
controller.play_btn.addEventListener(MouseEvent. CLICK, playSound);
controller.pause_btn.addEventListener(MouseEvent. CLICK, pauseSound);
controller.stop_btn.addEventListener(MouseEvent. CLICK, stopSound);
// play sound
function playSound(event:MouseEvent): void{
if(!isPlaying){
mySoundChannel65 = mySound65.play();
if(isPaused) {
lastPosition=Math.floor(mySoundChannel65.position);
mySoundChannel65 = mySound65.play(lastPosition);
isPlaying=true;
// pause sound
function pauseSound(event:MouseEvent): void{
if(isPlaying)
lastPosition=Math.floor(mySoundChannel65.position);
mySoundChannel65.stop();
isPlaying=false;
isPaused=false;
else if (isPaused){
mySoundChannel65=mySound65.play();
isPlaying=true;
isPaused=false;
// stop sound
function stopSound(event:MouseEvent): void{
SoundMixer.stopAll();
lastPosition=0;
mySoundChannel65.stop();
isPlaying=false;
Thanks in advance for any help.

Kglad:
Thanks for replying again. I fixed my script and it's working fine now. The final script is as follows:
var mySound65:Sound = new Sound();
var mySoundChannel65:SoundChannel = new SoundChannel();
var lastPosition:Number= 0;
mySound65.load(new URLRequest("sounds/pronouns.mp3"));
var isPlaying:Boolean = new Boolean();
controller.play_btn.addEventListener(MouseEvent. CLICK, playSound);
controller.pause_btn.addEventListener(MouseEvent. CLICK, pauseSound);
controller.stop_btn.addEventListener(MouseEvent. CLICK, stopSound);
// play sound
function playSound(event:MouseEvent): void{
if(!isPlaying){
mySoundChannel65 = mySound65.play();
isPlaying=true;
if(lastPosition>0) {
mySoundChannel65 = mySound65.play(lastPosition);
controller.play_btn.visible=false;
controller.pause_btn.visible=true;
// pause sound
function pauseSound(event:MouseEvent): void{
lastPosition = mySoundChannel65.position;
mySoundChannel65.stop();
controller.play_btn.visible=true;
controller.pause_btn.visible=false;
// stop sound
function stopSound(event:MouseEvent): void{
SoundMixer.stopAll();
lastPosition=0;
mySoundChannel65.stop();
isPlaying=false;
controller.play_btn.visible=true;
I added a couple of things:
a) To avoid clicking the same button more than once, I made either pause or play button invisible.
b) The solution was to include the following conditional in the play button:
if(lastPosition>0) {
mySoundChannel65 = mySound65.play(lastPosition);
Thanks again!

Similar Messages

  • TS3694 No sound and ringer button not working. I cannot play music but when I put my Iphone 4 on the dock it plays music. This happens when I updated my phone to IOS 6.1.3..The phone doesnt have any carriers we only used this just like Itouch. Please help

    Please help. Since I updated my Iphone4 to ISO 6.1.3...The ringer button not working, can't play any music (but ok with the dock), headphone sound is muffled. What can I do? I tried restoring and downgrading but it won't let me.

    Hi there,
    Thanks for reaching out to the community.
    Please help. Since I updated my Iphone4 to ISO 6.1.3...The ringer button not working, can't play any music (but ok with the dock), headphone sound is muffled. What can I do? I tried restoring and downgrading but it won't let me.
    It appears like you may have a hardware issue with your ringer button and internal speaker that came to light after the update. If you have already restored your iPhone back to factory settings using iTunes, you may need to have your phone serviced.
    Some potential good news... Check your headphone jack for lint. There may be enough to cause a muffled connection. You can try to blow it out with compressed air or very carefully pulling out any solid objects that may affect the connection.
    Best of luck!

  • Photos slideshow pause/play button not displaying in 3.0

    I've been running 3.0 on my first generation Touch for several months. Throughout, I've noticed that the Photos slideshow lower-center pause/play button no longer displays once I've paused a slideshow. While the left/right arrows show and I am able to advance photos one at a time, I am unable to re-engage the slideshow.
    In software versions 1 and 2, one could freely pause and play a running slideshow. Now, when I pause the slideshow, I'm forced to bail out of the slideshow and start a new one.
    A longtime Touch owner, I'm not certain if my problem is a 3.0 software glitch or things have changed. Has anyone else encountered the issue?

    Hi,
    look here: http://discussions.apple.com/message.jspa?messageID=9843694#9843694
    I hope Apple will fix this and some other Bugs in their 3.0.1 Update which will hopefully appears in a few days.

  • Allowing the Pause / Play buttons to work with VLC player

    I would like to use my pause / play buttons when I am using VLC player. I use VLC player to watch many movies, but I still use iTunes to play music, so I was wondering if there was a way to switch which application my play / pause button controls. Right now, even if VLC player is open it will only control iTunes.
    Thanks,
    Travis

    Under VLC preferences look for the options "Control with media keys" and "...when VLC is in background".

  • Brightness and Play buttons not working on BT Keyboard

    I have a Bluetooth, short aluminum kayboard. Earlier today my keyboard buttons for Brightness up, Brightness Down, Rewind, Play/Pause, Fast forward, all stopped working. My volume buttons still work though. I reset my PRAM, and made sure the F1,F2,F3, etc. box on keyboard preferences was not checked. I am running on Snow Leopard. I need help with this. Anyone have an idea on how to solve my problem?

    To see if it's Hardware or Software, plug a USB KB in to test with.

  • Pause/Play functionality not working with publish to HTML5

    Hi experts,
    I am creating a Captivate course to be deployed on iOS and publishing to HTML5. We are using custom buttons (not playback controls) for navigation to advance through the slides. My client would also like Play/Pause functionality for some of our embedded (MP4) videos. I used the following tutorial to create these buttons to toggle the Play & Pause functionality:
    http://www.youtube.com/watch?v=0v2F0NyEAfs
    This worked PERFECTLY when previewed in a browser from Captivate, but does not work when published and launched in HTML5 format, from the same browser. I didn't use any Flash content, rollover functionalities, or anything noted in the limitations list for HTML5 output. The conditional functions I have set for my buttons are:
    PAUSE:
    Hide > SPI_Pause
    Show > SPI_Play
    Assign > cpCmndResume with 0
    Assign > cpCmndPause with 1
    PLAY:
    Assign > cpCmndPause with 0
    Assign > cpCmndRsume with 1
    Hide > SPI_Play
    Show > SPI_Pause
    The issue I am encountering is that the video completely pauses itself the moment the pause button displays on the stage (no matter where I place it in the timeline). I'm not pressing it or anything, it just initiates the cpCmndPause function and disregards all the others I have set. From there the conditional sequences are rendered useless as the video is already paused even though I didn't press the button. I've verified this happens anywhere I try to use the cpCmndPause function.
    I am running Captivate 6.1.0.309 on Mac OSX 10.8.2. I've tested the HTML5 output in Chrome and Safari with the same results. I did see a thread regarding a patch install (for 6.0.1xxx) that resolved some issues, but this appears to be an earlier version of what I have installed so this should have been resolved with my install?
    Please HELP!

    So, was this issue NOT resolved with the patch, or is this an entirely new/different issue?
    It seems as though this functionality is pretty basic, so I don't understand why this is a restriction with HTML5 output? Please advise, if there are restrictions with advanced actions that are not noted in the HTML5 limitations documentation, then they should be.
    Thank you, I too have a client deadline and have purchased this subscription based on the documentation Adobe has provided about the application's ability to publish to this new format.

  • Play button not working in iTunes for music

    Ok, so I've got a new PC (Windows 8.1 and latest version of iTunes running) and have transferred my whole iTunes library across. Transfer (about 1 week ago) went smoothly and all media played back fine, including music.
    I've opened up iTunes today and my albums wont play back using a) double clicking on the album, b) right clicking and selecting play or c) the play button once the album expands - these methods all worked just 2 days ago which was the last time I used iTunes. The tracks will play if I drag and drop the album/tracks into the play bar at the top but they don't start automatically, I have to click the play button at the top. They will also play if I select all the tracks in an album and press return.
    I can add individual tracks to the current playlist and they will play when their turn comes but trying to add the whole album doesn't work, it just doesn't appear in the 'next up' list.
    So it's not a matter of iTunes not locating the files, they're all in the correct file location and are matching up. Other media; TV, film & podcasts all work fine. Another oddity is that iTunes works perfectly (methods a), b) and c) above) for the other user account on the same PC i.e. non of the problems experience in my account.
    Hopefully I've explained the problem ok but if not ask away. Has anybody come across this before and any solutions recommended?
    Thanks

    I have excatly the same issue.  i have tried everything.  It started when i updated to version 10 of itunes.
    Sorry i cannot help.  TIm

  • Flash MX - Sound on/off button not working properly.

    I used the tutorial found here. The 3 frames of my button are in a movie clip, within a keyframe in the main timeline. I used the code at the end in the tutorial for the first keyframe, so that the clip begins with music playing. However; I cannot get the buttons to work. I cannot stop the sound. Help please? I desperately need it.

    show the code you used.

  • Sound/Wifi switch buttons not working

    Hi,
    I just booted my computer (pavilion dv6-1120ek) up today & the tactile board isn't working anymore. The light is glowing, but doesn't react to my touch.
    Now I can only control sound via sound panel in Windows, but the real problem is the wi-fi, when I try to activate it through Windows, it says "Use the Switch on the front side of the computer, or function keys if available, to enable wirless capability on this computer".
    Please if there's anything troubleshooting, that would be great !
    Thanks in advance.
    This question was solved.
    View Solution.

    Hi,
    Try a Hard Reset as follows.
    Shut down the notebook, unplug the AC Adapter and then remove the battery.  Hold  down the Power button for 30 seconds.  Re-insert the battery, plug in the AC Adapter and start the notebook.
    Regards,
    DP-K
    ****Click the White thumb to say thanks****
    ****Please mark Accept As Solution if it solves your problem****
    ****I don't work for HP****
    Microsoft MVP - Windows Experience

  • AS3 Code Snippet (url button) not working in firefox

    Hi,
    This code works fine for my flash site:
    ovbutton.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage_5);
    function fl_ClickToGoToWebPage_5(event:MouseEvent):void
              navigateToURL(new URLRequest("http://www.starnavigation.ca/vision.html"), "_self");
    However, within firefox (7.0.1), once the back button is pressed the button does nothing. Works great with every other browser. It basically only works once, until I reload the page. Any ideas???

    Check if you have set "allowScriptAccess" to "allways".
    If you embed flash like this,
    <object classid=”clsid:D27CDB6E-AE6D-11cf-96B8-444553540000″
    codebase=”http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0″ width=”700″
    height=”322″>
    <param name=”movie” value=”intro.htm”>
    <param name=”quality” value=”high”>
    <embed src=”intro.htm” quality=”high”
    pluginspage=”http://www.macromedia.com/go/getflashplayer” type=”application/x-shockwave-flash” width=”700″
    height=”322″></embed>
    </object>
    you have to add it in two places: one is for IE and other for FF, Opera, chrome..
    <object classid=”clsid:D27CDB6E-AE6D-11cf-96B8-444553540000″
    codebase=”http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0″ width=”700″ allowscriptaccess="true"
    height=”322″>
    <param name=”movie” value=”intro.htm”>
    <param name=”quality” value=”high”>
    <param name="allowscriptaccess" value="true">
    <embed src=”intro.htm” quality=”high”
    pluginspage=”http://www.macromedia.com/go/getflashplayer” type=”application/x-shockwave-flash” width=”700″
    height=”322″></embed>
    </object>

  • Quick play button not working

    my HP Pavilion dv4-1240tx quickplay touch button doesnot launches quickplay and the volume touch buttons doesnot show visuals and no click sound too... somebody pl help me to solve this error..

    Okay, try installing the latest version of the HP Quicklaunch Button Software.

  • QUICK PLAY BUTTONS NOT WORKING

    My DV6000 series laptop quick launch buttons are lit up but they don't work.
    Any ideas please

    Hi,
    Write down Your p/n number which is under Your computer and looks like this.
    ** Say thanks by clicking the "Thumb up" icon which is on the left. **
    ** Make it easier for other people to find solutions, by marking my answer with "Accept as Solution" if it solves your issue. **

  • I have a 7th generation ipod, i have a problem with the pause/play button, it no longer works.

    I have a 7th generation ipod, i have a problem with the pause/play button, it no longer works.
    What does it take to make sure it works ????
    Thanks

    If you successfullt restore to factory defaults/new iPod and still have the problem then it is likely a hardware problem and an appointment at the Genius Bar of an Apple store is in order.

  • Button not working in browser

    I am coding a video player in Netbeans 6.8. just find two problems:
    1. the browser button not working in browser when I run the project from Netbeans under "run in browser" mode. however under "standard execution" mode, everything is fine.
    2. can not run the jar file in the project's dist directory directly. in other word, I can not run the jar file outside of Netbeans.
    I appreciate any help. thanks.
    Main.fx:
    package gui;
    import javafx.stage.Stage;
    import javafx.scene.Scene;
    import javafx.scene.paint.Color.*;
    * @author Jethro
    var face=Face{};
    function run(){
        Stage{
            title: "player"
            resizable:false
            scene: Scene{
                width:800
                height:600
                fill:DARKBLUE
                content: [face]
    }Face.fx:
    package gui;
    import javafx.scene.CustomNode;
    import javafx.scene.Group;
    import javafx.scene.Node;
    import javafx.scene.control.Button;
    import javafx.scene.layout.VBox;
    import javafx.scene.media.Media;
    import javafx.scene.media.MediaPlayer;
    import javafx.scene.media.MediaError;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.media.MediaView;
    import javafx.scene.control.ProgressBar;
    * @author Jethro
    public class Face extends CustomNode {
        public var lbf=LBF{};
        public var enable=true;
        public var mark="play";
        public var sourceOfMedia:String;
        public def player=MediaPlayer {
            repeatCount:MediaPlayer.REPEAT_FOREVER
            onError:function(e:MediaError){
                var er=e.message;
         media : bind Media {
              source: sourceOfMedia
        public def view=MediaView {
                mediaPlayer:bind player
                preserveRatio: true                    
        public def bar=ProgressBar {
                height:10
                width:bind scene.width
                progress: bind
                    if(player.media !=null){
                        player.currentTime.toMillis()
                            /player.media.duration.toMillis();
                    }else{
                        0.0
        public var play=Button {      
            onMousePressed:function(e:MouseEvent){
                if(enable and player.media != null){
                            mark="pause"; println("playing...");                       
                            sourceOfMedia=lbf.uri;
                            player.play();
                            enable=false;
                }else{
                    mark="play";
                    player.pause();println("paused...");
                    enable=true;
         text: bind mark       
        public override function create(): Node {
            return Group {
                content: [
                    VBox{
                        content: [
                            lbf,
                            bar,
                            play,
                            view,
    }LBF.fx:
    package gui;
    import javafx.scene.CustomNode;
    import javafx.scene.Group;
    import javafx.scene.control.TextBox;
    import javafx.scene.layout.HBox;
    import javafx.scene.paint.Color;
    import javafx.scene.shape.Rectangle;
    import javafx.scene.text.Font;
    import javafx.scene.text.Text;
    import javafx.scene.Node;
    import javafx.geometry.HPos;
    import javafx.geometry.VPos;
    import javafx.scene.control.Button;
    import javax.swing.JFileChooser;
    * @author Jethro
    public class LBF extends CustomNode{
        public var uri:String;
        public var whereis=Text {
            fill:Color.BLUE
         font : Font {
              size: 20
         x: 10, y: 30
         content: "location: "
        public var location=TextBox{
            text:"the song's location"
            columns:40
            selectOnFocus:true
        public var browser=Button {
         text: "Browser"
         action: function() {
                    var jfc=new JFileChooser();               
              jfc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
                    var val = jfc.showOpenDialog(null);
                    if(val == JFileChooser.APPROVE_OPTION) {                   
                        location.text = jfc.getSelectedFile().getAbsolutePath();
                        uri=jfc.getSelectedFile().toURI().toString();
                        println(location.text);
        public var face=Group {
         content: [
              Rectangle {
                        x: 0, y: 0
                        width: 800, height: 50
                        fill: Color.SILVER
                     HBox{
                         width:800
                         height:50
                         hpos:HPos.CENTER
                         vpos:VPos.CENTER
                         spacing:5
                         content: [whereis,location,browser]
        public override function create():Node{
            return face;
    }

    thanks for your reply but I need more specific operation.
    maybe I am not very clear about the problem one. I mean when I run the code in standard mode, if I click the browse button, a window will pop out and I can choose a video file from my local harddisk. but if I run it in "web start execution" mode and "run in browser" mode. the browse button make no response when I click it.
    Edited by: Phoenix2006 on Feb 8, 2010 2:35 PM
    Edited by: Phoenix2006 on Feb 8, 2010 2:37 PM
    Edited by: Phoenix2006 on Feb 8, 2010 2:42 PM

  • Music buttons not working in lock screen on my iPhone 4 after iOS7 update.

    After I updated my iPhone 4 to iOS7, the music buttons like PLAY, REWIND and FORWARD are not working in the locked screen as well as on swipe up menu. Any resolution please?

    hi there
    i had a problem with my wifes iphone 4s, today morning while travelling to work i changed a setting on repeat option and changed it to repeat artist, it was fine until when i finish my work and on my way back i found songs are not playing anymore, lots of stop signs next to my song list, play/pause button not working, album arkwork keep moving from one to another on its own, so after i reach home i try to do some research on Apple support communities, try to soft reset my phone closing all the apps on background didnt work, also note that control centre music player was not working as well. none of the solutions worked. after trying for two hours i found out that the trouble is in repeat options , so i changed it from repeat artist to repeat off. and the music start playing as usual, but i still have those stop buttons next to the songs i tried to play earlier. At least it fixed temporarily. please also note that in the meantime i tried to sync my phone with the pc and suddenly its start syncing all the songs again assuming there were no songs on my iphone.  so guys i think soft reset might not help all the time but try to remember what settings you changed recently and change it back to the original option, not sure ,but it might help.

Maybe you are looking for

  • Importing AVI into FCE has out of sync audio, but not in iMovie?

    Hi all, I'ave searched around and can't seen to find this issue in other parts of the forum, so thought I would try posting up. I'm using a GoPro camera which creates AVI files at 27fps, 512 x 384, Mono Audio, 8.0KHz, 32-bit Floating Point. I'm total

  • How to turn a byte[] into an image?

    My app downloads image data from a server, storing the data in a byte[] called imageDataByteArray. I want to use imageDataByteArray to create an image. For this, I have tried using: int w = imageWidth; //488 int h = imageHeight; //245 int imageOffset

  • Magic Mouse Two Finger Swipe

    I've had a magic mouse for quite awhile but there's one thing that has never worked correctly: two finger swipe. When trying to use the gesture to navigate through web history or pictures, it will only work going backward (left swipe). When I swipe t

  • How to add Text fields while doing SO through LSMW-BAPI method

    Hi Friends, I am doing Sales Order data migration using LSMW-BAPI method. The BAPI that i'm using is SALESORDER_CREATEFROMDAT2 I am able to handle all the fields except for the text fields such "Material sales text"  in the Item info and "Layoout Set

  • Why can't my Ipad2 connect with any bluetooth devices?

    My Ipad 2 cannot connect to anything. I bought a keyboard that is compatible with the Ipad 2 recently, and when i tried to connect them an error will always occur. My Ipad can see the keyboard so i click on it, and it tells me to put a pin number on