2 Replies Latest reply on Dec 14, 2016 10:19 AM by ClayUUID

    Stop Any Rendering SetFPS = 0 doesn't work

    александрб62780587 Level 1

      How can I stop any render for Canvas?

       

      Generate part an html file in Adobe Animate CC

       

      ......

        //Registers the "tick" event listener.

        fnStartAnimation = function() {

        createjs.Ticker.setFPS(10);

        createjs.Ticker.addEventListener("tick", stage);

        }

      ......

       

      I wrote a function but  call SetFPS(0) doesn't work

       

      function SetFPS(value){

        alert(value);

        if(value ===0){

             createjs.Ticker.setFPS(0);

             createjs.Ticker.setPaused(true);

        }

        else{

             createjs.Ticker.setFPS(value);

        }

      }

        • 1. Re: Stop Any Rendering SetFPS = 0 doesn't work
          александрб62780587 Level 1

          I rewrote function SetFPS.

           

          var isStop = false;

          function SetFPS(value){

            if(value ===0){

                 if(!isStop){

                      createjs.Ticker.removeEventListener("tick", stage);

                      isStop = true;

                 }

            }

            else{

                 createjs.Ticker.setFPS(value);

                 if(isStop){

                      createjs.Ticker.addEventListener("tick", stage);

                      isStop = false;

                }

            }

          }

          • 2. Re: Stop Any Rendering SetFPS = 0 doesn't work
            ClayUUID Adobe Community Professional

            setFPS() is just a convenience function for setting the ticker's interval property. All it does is:

             

            Ticker.setInterval(1000/value);

             

            So if you try setFPS(0) it does 1000 divided by zero, which evaluates as Infinity. This is not a legal value for intervals.

             

            Now, what you can do is setInterval(9007199254740991). This is the maximum integer in Javascript (2^53 - 1). In fully ES6-compliant browsers this value can be referenced as Number.MAX_SAFE_INTEGER, but Internet Explorer doesn't support it, so you have to use the literal. Or you could do Math.pow(2, 53). In any case, while this won't technically stop the timeline from advancing, it will slow it down to a rate of one frame every 285.6 millenia. This should be sufficient for your needs.

            1 person found this helpful