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

HTML Canvas tween with a random wait();

Explorer ,
Jul 11, 2019 Jul 11, 2019

Copy link to clipboard

Copied

I looking for a more efficient way to tween (alpha) about 50 movieClips all from the same library movieClip with different instance names:

I could dupliacte this 50 times but that would be very efficent

createjs.Tween.get(this.movieClip).wait(200).to({alpha:1}, 400, createjs.Ease.quadOut);

...

...

It would be much better to randomise the number in the wait() parameter and have the instance name have a multiple of a number e.g this.movieclip1 etc

Any help would be appreciated.

Views

358

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

correct answers 1 Correct answer

Community Expert , Jul 11, 2019 Jul 11, 2019

Hi.

One approach would be to place all of your instances inside of a container and then access the children property of this container to reference each child. Like this:

var root = this;

root.tweenBalls = function(e)

{

    stage.off("drawstart", root.drawStart);

    root.balls.children.forEach(function(ball) // the container is called balls

    {

          ball.alpha = 0;

          createjs.Tween.get(ball).wait(Math.random() * 5000).to({alpha:1}, 400, createjs.Ease.quadOut);

    });

};

root.drawStart = sta

...

Votes

Translate

Translate
Community Expert ,
Jul 11, 2019 Jul 11, 2019

Copy link to clipboard

Copied

Hi.

One approach would be to place all of your instances inside of a container and then access the children property of this container to reference each child. Like this:

var root = this;

root.tweenBalls = function(e)

{

    stage.off("drawstart", root.drawStart);

    root.balls.children.forEach(function(ball) // the container is called balls

    {

          ball.alpha = 0;

          createjs.Tween.get(ball).wait(Math.random() * 5000).to({alpha:1}, 400, createjs.Ease.quadOut);

    });

};

root.drawStart = stage.on("drawstart", root.tweenBalls, null, true); // we need the drawstart event so children will be ready to be accessed

Please let me know if this helps you.

Regards,

JC

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
Explorer ,
Jul 11, 2019 Jul 11, 2019

Copy link to clipboard

Copied

Work perfectly

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 ,
Jul 11, 2019 Jul 11, 2019

Copy link to clipboard

Copied

LATEST

Excellent!

You're welcome!

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