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);
}
}
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;
}
}
}
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;
}
}
}
Copy link to clipboard
Copied
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.