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

html5 coding: start creatjs.tween at a special time (automatically)

New Here ,
Feb 08, 2018 Feb 08, 2018

Hi there!

The image „Mov_Image_Inst“  should be visible, scale and rotate between minute 30 to 31 (and this every new hour again).

This is my coding:

var _this = this;

var d = new Date ();

var M = d.getMinutes();

var S = d.getSeconds();

this.Mov_ImageTween_Inst.visible = false;

if (

    M >= 30 && M<31  && S >= 0 && S <59

) {

   this.Mov_ImageTween_Inst.visible = true;

   this.Mov_AffiTween_Inst.alpha = 0;

   createjs.Tween.get(this.Mov_ImageTween_Inst)

   .to({alpha:1, scaleX: 2, scaleY: 2}, 1000)

   .to({rotation: 360}, 5000)

   .to({alpha:0, scaleX: 1, scaleY: 1}, 1000);

};

The code is almost correct, but the tweening doesn´t start automatically between minute 30 to 31, a website refresh is needed.  How can I get the tween to start at the right time automatically? Visiblity scaling and rotation between minute 30 to 31 works after website refresh only but not automatically.

Any help is appreciated.

Thank you in advance.


Cheers. Henry

562
Translate
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

LEGEND , Feb 16, 2018 Feb 16, 2018

Explanation and solutions here:

Re: HTML 5 Mouseover button targeting

Translate
LEGEND ,
Feb 08, 2018 Feb 08, 2018

Put that code inside a function. Make that function be called once a minute by using setInterval().

WindowOrWorkerGlobalScope.setInterval() - Web APIs | MDN

If you need the animation to happen precisely at a certain time, it would probably be okay to set the interval to once a second even.

Translate
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
New Here ,
Feb 08, 2018 Feb 08, 2018

Thanks. It shouldn´t be an interval, it shoud be a special time in minutes and seconds. Cheers.

Translate
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 ,
Feb 08, 2018 Feb 08, 2018

Well, there's no specialTimeInMinutesAndSeconds() function in JavaScript, so you're going to have to use an interval to monitor the current time.

Translate
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
Participant ,
Feb 08, 2018 Feb 08, 2018

A more optimal way is using ClayUUID suggestion. Just convert your 30 minutes into 1.8e+6 milliseconds.

A less optimal way would be to create a ticker event listener that runs through your check, you can probably change the rate to every 5 seconds or something....

Regards,

Translate
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 ,
Feb 08, 2018 Feb 08, 2018

I'm assuming he means every 30 minutes/hour of wall time, not run time, in which case he's have to adjust the initial delay based on time remaining to the next "special" time.

Translate
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
Participant ,
Feb 08, 2018 Feb 08, 2018

Ah, yes i get you..

So we would need a new set of variables that record/set the initial time based on launch/initiation.....

Translate
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
New Here ,
Feb 16, 2018 Feb 16, 2018

Hi, thank you for your help so far. I ´ve tried the setInterval() method.

This works:

function runTheClock()

{

alert("hello");

}

var interval = setInterval(runTheClock, 1000);

And this works:

createjs.Tween.get(this.Mov_Symbol_Inst).to({rotation: 360}, 2000);  

But the combination doesn't work:

function runTheClock()

{

createjs.Tween.get(this.Mov_Symbol_Inst).to({rotation: 360}, 2000);  

}

var interval = setInterval(runTheClock, 1000);

Thank you in advance!

Translate
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 ,
Feb 16, 2018 Feb 16, 2018
LATEST

Explanation and solutions here:

Re: HTML 5 Mouseover button targeting

Translate
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