Play Pause feature question

I want to use the functionality of pause play in one of the animations.

He needs control the following things.

1 to pause the sound and the animation when the user clicks the pause button.

2 play the sound and the animation when the user clicks the pause button.



Now, I have this code I have a stuck below tutorial. After the publication, I get the following errors

  1. Access of undefined property btn. (I've marked problems in the code)
  2. The sound has provided the link to that music plays not at all.

Note: it will be great if anyone can provide the code compatible with Flash CS6 and or provide a complete code which play/pause the timeline and also play/pause audio.


------------------------------------------------------------------------------------------ ----------------------------------

CODE :

import flash.media.SoundChannel;

import flash.events.MouseEvent;

import flash.events.Event;

var isPlaying:Boolean = true;

var lastposition:Number = 0;

var mysound:music = new music();

var soundchannel:SoundChannel = new SoundChannel();

SoundChannel = mysound.play (0,0);

soundchannel.addEventListener (Event.SOUND_COMPLETE, onPlaybackComplete1);

function onPlaybackComplete1(event:Event):void

{

lastposition = 0;

SoundChannel.Stop ();

btn.btn_pause.visible = false;

trace ("finished");

isPlaying = false;

}

/ * end of part 1 * /.

btn.addEventListener (MouseEvent.CLICK, playsound);

function playsound(event:MouseEvent):void

{

If (! isPlaying)

{

SoundChannel = mysound.play(lastposition,0);

btn.btn_pause.Visible = true;

isPlaying = true;

}

on the other

{

lastposition = soundchannel.position;

SoundChannel.Stop ();

btn.btn_pause.visible = false;

trace (lastposition.toFixed (0), mysound.length.toFixed (0));

isPlaying = false;

}

soundchannel.addEventListener (Event.SOUND_COMPLETE, onPlaybackComplete);

function onPlaybackComplete(event:Event):void

{

lastposition = 0;

SoundChannel.Stop ();

btn.btn_pause.visible = false;

trace ("finished");

isPlaying = false;

}

}

Stop();

You must correct the errors of the compiler before you can even begin to debug your code.

to begin with, you have no object named btn on stage so you don't create with code.  fix this.

Tags: Adobe Animate

Similar Questions

  • Satellite E100-004 - can I disable media buttons as mute, play pause

    My laptop is Toshiba Satellite E100-004.
    is there a way disable the multimedia button panel (Media buttons on top of keyboard - mute-media-play/pause-stop-rewind-forward-)?

    thanx

    Hello

    Please don't be crazy on my but I don't understand your question. These buttons are by default configured to run with pre-installed Windows media player. If you don't like them you just simply do not touch them.
    I know that you can change the browser settings and the multimedia key and define which application should be open with these buttons.

    In any case such option is unknown to me.
    Why you want to disable these buttons?

  • Satellite A200-1AG: can use the play, pause buttons with other software?

    Hey

    I have question about my satellite A200-1AG.
    It's as well as the power button some other which are assigned to media player.
    Can I reprogrammed in some way to the music of change/play/stop/skip with the buttons?

    I never use media center, I know it is asigned a deflaut with the toshiba Vista Home recovery disk, but I just use winamp

    Is there a solution?

    No, as far as I know you cannot reconfigure the keys like play, pause, stop, etc.
    They can be used only with WMP (windows media, media center player)

  • Is it possible to change the function of the buttons play/Pause on Satellite P100-347

    Hello.

    I would like to would like to know if there is a way to change the play / pause button on my phone to stop the opening of windows media Center. I like to use itunes to listen to my music and the other buttons (back, forward and stop), all work with other programs, but there is no way to use the play and pause function without opening of the Media Center.

    It seems that you can only change the internet and function of CD/DVD in the Panel.
    Thanks in advance.

    Hello

    Just reply: no, not possible to change playback / pause feature keys s

    The Toshiba control utility offers two options.
    It allows you to assign and select a program for the internet button and touch CD/DVD.

  • "Play To" feature inoperable

    I have a PS3 and I am running Windows 7RC, (which I love). However, the "Play To" feature much Hype does not work. 7RC Win can't find even the PS3 to enable the "Play To" feature to work. The PS3 can find all the files on the computer that I use as my media server. Non - Win 7RC systems can find both shared media. However, I don't see the PS3, the Wii, the DVR, etc.. On top of this problem, has been cutting the video streaming from other systems, data transfer directly to the Win 7RC systems cannot see the works as long as I'm not sending the files of the Win 7 machine. And a hard transfer to the drive or the driver or USB memory card works fine. For a feature that was then very hype for the THESE, it seems like it should work. And I waited patiently updates since the beta was released without result. When are you going to fix this flaw that was supposed to be one of the main features?

    Hello CyR00k,

    Please use the Forums for Microsoft Windows.

    Sorry, you are having this problem!  You try to use other devices like an Extender?  Have you ever been able to connect your PS3 correctly with your computer?

    I suggest you post this question on the link below for the Windows 7 Forums.   The link below will take you to the Windows 7 support forum.  You can search FAQS as well as post.  Thank you!

    Windows 7 Media:
    http://social.technet.Microsoft.com/forums/en/w7itpromedia/threads Engineer James Microsoft Support answers visit our Microsoft answers feedback Forum and let us know what you think.

  • Play/Pause for the SmartBand swR10 problem

    Hello

    The only question I have now with my SmartBand SWR10 is so is not play/pause my media file. Does anyone else have this problem apart from me?

    I don't have a Smartphone Sony but a Samsung Galaxy S5 and everything seems to work fine, but a problem with the tap once for the play/pause is annoying me. I can still go and return songs, but every time I type once he just stops for a split second then continues to play.

    Your comments would be greatly appreciated.

    On Z1, it works pretty well. Have you tried a reboot of your SGS5? It records all the water from the tap correctly however.

  • How to toggle the play/pause with the click of the mouse on wmp?

    Most of the players have the option to activate the mouse click play/pause on the video player.

    How can I activate this feature in windows media player?
    Thank you.

    Hi DGinz,

    To play/pause in Media Player, you must use the keys.

  • Lost "Play To" feature after I lost internet...

    Hi, could someone help me get the "Play To" feature on?

    I lost my internet today for a few hours and when she came back, the function 'play to' had disappeared.

    Thank you!!

    Friday, February 6, 2015, 22:10:19 + 0000, MarkPacana wrote:
     
    > Hi, could someone help me get the "Play To" feature on?
    >>
    > I lost my internet today for a few hours and when she came back, a "play to" feature has disappeared
     
    Restart your router, your computer and power cycle the device you want to
    "Play to." probable IP changed on your network addresses.
     
    What you play in? do you target the device in the network window
    After the restart, etc.?
     
     
     
    __________________________________________________________________________________________________
    Barb
    MVP Windows Entertainment and connected home
     
    Please mark as answer if that answers your question
     
     
     
  • Control edge file animate OAM with the buttons play/pause of Captivate on the skin.

    Hello world

    I worked on a project where I mix a variety of objects and animations.  I do animations animate on board.  The problem I have is that when the user clicks the button pause on the Captivate playback controls, the oam file do not pause.  I found descriptions of how I can make an animation to play/pause the Captivate timeline button on board, but I can't find anything on the use of the Captivate pause button to control the Edge file animate.  Discussions only that I managed to find on that seem to be the answer.  Someone had a bit of luck with this question?

    Any advice would be appreciated.

    Thank you

    Randy

    OK, it's a bit hacky, but it works quite to control the main timeline object in a file of edge of Cape Town, where the Edge file has been imported to Cap 9 as a Web (oam) object. I went seeking answers same like you and came from vacuum, then start to tinker myself and came across the following method.

    Let's use window.postMessage to send a string between Cape document window and document edge iframe window then react accordingly. You can learn more about postMessage accepted battery answer here: http://stackoverflow.com/questions/3076414/ways-to-circumvent-the-same-origin-policy

    In your dashboard file click the support of Actions for the stage object in the timeline and select the compositionReady event. Paste this code into the text window:

    addEventListener for Chrome, attachEvent for IE

    window.addEventListener ('message', receivedFromCaptivate, false);

    window.attachEvent ('onmessage', receivedFromCaptivate);

    function receivedFromCaptivate (event) {}

    switch (event.data) {}

    case "play":

    SYM. Play();

    break;

    case "pause":

    SYM. Stop();

    break;

    }

    }

    Save the file and publish it as an oam, then import the OLS in a slide of Cap, as you normally would. Now, to put in place things of the CAP. Here is a visual aid for the rest of the explanation...

    In the PAC file select the control that you use to start playing the chronology of the edge (in the example above the "slide4Play"), select the checkbox 'Use as button' in the properties on the right, select the "Actions" tab, then to the drop-down list for 'Success' choose "Execute advanced Actions." Click the folder next to the selection of Script control and advanced Actions dialog box should appear. Name your action something (for example, "playEdgeSlide4"), then click the 'Add' in the grey bar to add a new action in the queue. In the drop down "Select Action"... ", choose"execute Javascript. "In the drop down menu"select the window... ". ", choose"current ". Then click on the 'Script_Window' button to bring up a window of text Javascript crap. In this window, you can paste this:

    try {}

    $("iframe") [0].contentWindow.postMessage ("play", "*");

    } catch (e) {}

    Console.log (e.message);

    }

    Select 'OK' to close the window of text Javascript crap, then click the 'Update Action' button to save your new action. Now let's do the same for break action - select the control that you use to pause, go through the steps above, the name of the action, implement advanced action in the same way and in the Javascript crap text window, paste the following text:

    try {}

    $("iframe") [0].contentWindow.postMessage ("break", "*");

    } catch (e) {}

    Console.log (e.message);

    }

    Cap incorporates the Edge file in an iframe on the page that has its own document window. In order to communicate between base ceiling windows and the iframe, we use the postMessage call. So when you hit your button Pause/Play in Cape Town, he publishes an event to the function that gets recorded in the iframe on board. And in the event.data is the string we send above the Cap base window in the function postMessage ('play' or 'pause'). We use a simple switch to react to the data string, stop or have fun with the main symbol of the scene at the edge (sym.play(1000) (), sym.stop ()).

    I hope this helps!

  • Can I use a USB pedals to control Play, Pause and reverse in first Pro CC?

    What I can or ever be able to use a USB pedals to control Play, Pause and reverse in first Pro CC?

    This would specifically for the production of subtitles.

    Play... listen... pause... translate... repeat, repeat, repeat etc...

    First looks almost as good as MacCaption if it had the ability to use a pedal USB instead of the JKL keys it could make it much more user-friendly for our Transcriber of closed caption.

    It must use the keyboard to type or transcript and must switch from windows by clicking on the window, she needs to handle.

    IF she could continue to type and use only the pedal to play, pause, reverse the playback head and still be able to keep typing in its captions window that would greatly simplify the process.

    Can present you this as a feature request?

    Thank you.

    rburleson wrote:

    Can present you this as a feature request?

    You can do so here:

    Feature request/Bug Report Form

  • The 2015 After Effects preview CC button is play/play/pause play/pause not

    I hit space > it starts to play and the play icon in the preview window changes to play/pause icon

    I hit the new space > continues to play and play/pause icon becomes a stop icon.

    I hit the new space > it finally stopped.

    Is there a way to make the space bar just play/pause rather than play/play/pause? No doubt I'm missing something obvious.

    I agree, it's great to see what is happening while he is in charge of these frameworks. I read this article before, I started this thread, but this setting is not adjustable. He will begin the playhead to preview or the beginning of the timeline, but the second time game is struck some parts where it loaded frames up, rather than jump at the beginning. I would like to see a preview in real time of the read head in order to the passage of time to the audio. I guess it will just take some getting used to.

    I think a lot of the questions overview I have are around audio synchronization. The images load fine, but audio playback is in every sense. I hear that they are planning on fixing these bugs in July.

  • Audio masking and play/pause NAV custom from quiz slides

    I have a custom in my CP6 project navigation:

    • Previous slide and the following page are intelligent forms on my master slides.
    • Turn on/off and Play/Pause are intelligent forms that switches (via the tip action). These direct on my first series of slide and are without title to last until the end of the project.

    On non-quiz slides where I don't want everything play control, I use a model of slides without the prev & next buttons and have a sur-Entrez action to hide persistent toggle buttons.

    Don't know if it's the most elegant solution - feel free to suggest another.

    But my question is: what is the best way to hide the fins on the blades before the test & quiz? (Can't make a sur-Entrez action.)

    Hi Tara,

    I group all the objects that must be hidden and use the on enter event drag to hide the group. If anything else needs to be done by entering in these slides, you can use an action smiple on first pre-test/Quiz slide. Be sure to show the Group on the first slide where you want to see the toggles that appear.

    Lilybiri

  • No taskbar of Youtube (play, pause, volume control / sound, etc.)

    Get no bar of tasks of YouTube, or control bar (play pause, noise level, etc.). . just a black screen, no his and no bar to order at the bottom of the black screen.

    All comments and replies to the messages displayed, but no way to click or start the video.

    In addition, on the homescreen of Youtube, stipulates the following:
    Hello, you seem to have disabled JavaScript. Please activate to see search results properly.

    Accordingly, I've updated Javascript, Flash and did some Javascript is ENABLED. Again no taskbar. that will allow me to play videos from YouTube.

    PS: HAVE TO USE Firefox 34 result of all subsequent updates in the Application JavaScript error message:

    'Top' getter called on an object that does not implement the Windows interface

    HELP & Thank YOU!

    Well, if you do not receive the messages in Firefox safe, it must be your extensions. Unfortunately, I don't have a way of knowing that one is, then several trials and errors, I think.

  • Is it possible to change the link to the WMP to Play/Pause/Stop buttons

    Is it possible to change the link to the WMP to play/Pause and the Stop button?
    Because network alone and media buttons can be changed by the software.
    And I'd rather not WMP for my favorite media player.

    Unfortunately, the buttons are configured with WMP (if the CD is inserted) and WinDVD (if the DVD is inserted).
    I guess that you can not use buttons with 3rd party applications.

  • Satellite L20: Play / Pause button have no action

    Nice day!
    Sorry for my English. It is not very good. But I will try to describe a problem with my laptop. :)

    Then... Problem with media - Play/Pause button.
    All other buttons (back, forward, stop) are working properly.
    But the Play/Pause button just launch Windows Media Player 11, when I press it.
    But do not play or pause in the drive. Button Stop Stop playback in the drive, return buttons and next to work according to its tasks. Only the button Play/pause have NO effect in the reader.

    What is the problem in?
    Can I count your s help?

    Thanks for the eyes on my problem. :)

    He s strange because usually utility Toshiba controls control media buttons.
    But this tool is not available on the page of the Toshiba driver

    Have you received the CD tools & utilities?
    Are there any programs or tools called controls buttons or something like that? Install it!

Maybe you are looking for

  • Freeplay on the screen - Sat M30x

    I have a M30X and when the screen is 90 degrees to the keyboard there are about 10-15 mm from freeplay - is that okay or do I need to put an end to a service partner Thank you very much DRAF.

  • Satellite A75-S211 is very slow

    I've been to a malware expert forum and posted Hijack this logs and this machine is more than likely own. Awhile back, we had to replace the modem due to problems of dispersal of heat (so they said) and I fear that the thing is about to fry itself no

  • Question about reinstalling operating system via external USB CD/DVD

    Hi all. I need to reinstall the operating system on my portege m200, but I have a lot of problems: (1) the recovery DVD seems to not work on my external USB dvd drive(2) at the start, it is impossible run any OS on cd USB external dvd drive, so I can

  • compare two tests

    Hi all Is it possible to compare two tests and see the result in any video format (graph, or something) If so, how can I go to it. ?? in the script, which is possible both manually... Thank you Skin rash

  • Problem adding music to Windows DVD Maker

    I try to add music (that I bought and downloaded on itunes) on a DVD that I make in the creation of Windows DVD and is not recognize the files... any suggestions?