• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

setTimeout not working in Animate

Community Beginner ,
Oct 31, 2020 Oct 31, 2020

Copy link to clipboard

Copied

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");
}

Views

728

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 31, 2020 Oct 31, 2020

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 31, 2020 Oct 31, 2020

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 02, 2020 Nov 02, 2020

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 02, 2020 Nov 02, 2020

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 02, 2020 Nov 02, 2020

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 02, 2020 Nov 02, 2020

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 02, 2020 Nov 02, 2020

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2020 Nov 08, 2020

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 02, 2020 Nov 02, 2020

Copy link to clipboard

Copied

.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 08, 2020 Nov 08, 2020

Copy link to clipboard

Copied

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.

😉

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 08, 2020 Nov 08, 2020

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 11, 2020 Nov 11, 2020

Copy link to clipboard

Copied

LATEST

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.:)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines