Skip to main content
Known Participant
October 31, 2020
Question

setTimeout not working in Animate

  • October 31, 2020
  • 7 replies
  • 1454 views

I have the following code at a certain frame in a move clip. I want the action to pause for 1 minute before move to "Ob2" frame. What am I doing wrong?
this.stop();
setTimeout(myFunction,60000);
function myFunction() {
this.gotoAndPlay("Obj2");
}

    This topic has been closed for replies.

    7 replies

    Known Participant
    November 8, 2020

    I am not building a Flash movie. I am converting a Flsh movie into and htlm5 canvas doeument. Here is the code that works perfectly:

    this.stop();
    setTimeout(this.play.bind(this), 3000);

    It pauses the action at the frame the code is placed and continues to the next this.stop(); Yes it is Java. But as far as I know as3 will not work for html5 canvas documents The code above works great.I have hundreds of places in my project.that I need to do this and it works every time. The code above does the following:

    It stops the movie at the frame where it is placed.
    Pauses for 3 seconds.

    Then continues to the next stop.
    Thanks for your help.

    😉

    Legend
    November 8, 2020

    It's JavaScript, not Java. Completely different languages.

    Known Participant
    November 11, 2020

    Please excuse me for saying Java instead of Javescript. I noticed it right after posting the pervious post. I just see noway to edit after posting. But correcting a typo does nothing to fix my problem.  But thank you for correcting me.:)

    kglad
    Community Expert
    Community Expert
    November 3, 2020

    .

    Known Participant
    November 3, 2020

    I know actionscript is history. I am working with html5 canvas. Flash is gone in December.

    kglad
    Community Expert
    Community Expert
    November 8, 2020

    correct, flash is history.  but it's incorrect to say or even imply as3 is history: mobile and desktop apps using as3 are still supported and working though i have my own doubts about the longevity of as3 mobile apps.

    kglad
    Community Expert
    Community Expert
    November 2, 2020

    for others, that's javascript, not actionscript which the op failed to indicate.  (and the confusion between Ob2 and Obj2 is unresolved, though maybe one is a forum typo.)

    Legend
    November 3, 2020

    "this." in front of stop() and gotoAndStop() is always an indicator of Canvas documents.

    kglad
    Community Expert
    Community Expert
    November 3, 2020

    saying "always" is incorrect.

     

    if that code failed in as3 you'd have a point, but as you know that code with "this" works perfectly well in as3.

    Known Participant
    November 2, 2020

    The problem was the code I was given for it to work was wrong. This is the correct code.

    this.stop();
    setTimeout(this.play.bind(this), 3000);

    This works without a click on a button. I just wanted to pause the action without any user interaction.
    I forget where I found it. But it works.

    Legend
    November 1, 2020

    Maybe you should put an alert statement in the timeout handler function to determine what exactly it is that's not working.

    kglad
    Community Expert
    Community Expert
    October 31, 2020

    flash is history but as3 can still used in mobile and desktop apps.