stop()

Stop the timeline.

Syntax stop()

Return Type Timeline

Description

Stop the timeline which will stop running the function specified by setLoop().

Return Value

Timeline. Returns the timeline object itself.

Examples

Example 1

We create a new core instance and a rectangle that we add to the canvas. Then we set the loop function which will increase the rotation of the rectangle by 1 degree. Then we start the timeline by appending the start() call to the setLoop() method. Finally we add an event handler to the rectangle, which will stop the timeline when the rectangle is clicked.

View Example
Code
var canvas = oCanvas.create({
	canvas: "#canvas",
	background: "#ccc",
	fps: 60
});

var rectangle = canvas.display.rectangle({
	x: 177,
	y: 170,
	origin: { x: "center", y: "center" },
	width: 200,
	height: 100,
	fill: "#000"
});

canvas.addChild(rectangle);

canvas.setLoop(function () {
	rectangle.rotation++;
}).start();

rectangle.bind("click tap", function () {
	canvas.timeline.stop();
});
Output