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

Stop Any Rendering SetFPS = 0 doesn't work

Explorer ,
Dec 13, 2016 Dec 13, 2016

Copy link to clipboard

Copied

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);

  }

}

Views

409

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

Explorer , Dec 14, 2016 Dec 14, 2016

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;

      }

  }

}

Votes

Translate

Translate
Explorer ,
Dec 14, 2016 Dec 14, 2016

Copy link to clipboard

Copied

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;

      }

  }

}

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
LEGEND ,
Dec 14, 2016 Dec 14, 2016

Copy link to clipboard

Copied

LATEST

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.

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