Skip to main content
Inspiring
February 28, 2021
Answered

HTML5 canvas -Ticker question to execute functions eg: this.on("click", clickHandler, here, false);

  • February 28, 2021
  • 1 reply
  • 480 views

I keep seeing the Ticker being used to execute functions. I just wanted to clarify a few things.

It seems to be used when something is loading ie: check to see if the object is loaded then execute the function.

What's the difference between 

this.on("click", clickHandler, here, false);

AND

createjs.Ticker.on("tick", ckickHandler);

Also, in the old days, you had to use am add event listener to check if the stage was added, then execute the code. I think it was also a bad idea to put code on the first frame.

Do we need to add anything to our HTML5 canvas first frame?

 

    This topic has been closed for replies.
    Correct answer kglad

    thie "click" event occurs once each time the user clicks (mousedown and mouseup) something.

     

    the Ticker "tick" event executes repeatedly at the framerate of the project.  so, it's ideal to use for checking to see if something has occured yet, and if not, check again a fraction of a second later.

     

    typically, when that something has occured something is done AND the Ticker "tick" loop is terminated (with removeEventListener or the off method).

     

    generally, nothing needs to be added to a html5 first frame but it would be unusual to put nothing in the first frame.

    1 reply

    kglad
    Community Expert
    kgladCommunity ExpertCorrect answer
    Community Expert
    February 28, 2021

    thie "click" event occurs once each time the user clicks (mousedown and mouseup) something.

     

    the Ticker "tick" event executes repeatedly at the framerate of the project.  so, it's ideal to use for checking to see if something has occured yet, and if not, check again a fraction of a second later.

     

    typically, when that something has occured something is done AND the Ticker "tick" loop is terminated (with removeEventListener or the off method).

     

    generally, nothing needs to be added to a html5 first frame but it would be unusual to put nothing in the first frame.