Skip to main content
Inspiring
July 9, 2019
Answered

canvas js have a delay or wait() before running the following code

  • July 9, 2019
  • 1 reply
  • 2991 views

I have been trying to find a way of delaying the running for the js code in a html canvas document.

I know how it is done with tweenjs e.g

createjs.Tween.get(this.movieClip).wait(200).to({scaleX:1.10,scaleY:1.10}, 100, createjs.Ease.quadOut);

But I want to delay or wait in running the following code instead of waiting on a tween:

this.movieClip.gotoAndPlay("frameName");

This topic has been closed for replies.
Correct answer JoãoCésar17023019

Hi.

Use the setTimeout method.

Window setTimeout() Method

Like this:

var root = this;

setTimeout(function()

{

    root.movieClip.gotoAndPlay("frameName");

}, 200);

Regards,

JC

1 reply

JoãoCésar17023019
Community Expert
JoãoCésar17023019Community ExpertCorrect answer
Community Expert
July 9, 2019

Hi.

Use the setTimeout method.

Window setTimeout() Method

Like this:

var root = this;

setTimeout(function()

{

    root.movieClip.gotoAndPlay("frameName");

}, 200);

Regards,

JC