removeChildAt() (since version 2.9.0)

Remove the object at the specified index from the canvas.

Syntax removeChildAt(index [, redraw])

Return Type Core

Description

Remove the object at the specified index from the canvas. This will trigger a redraw of everything unless specified otherwise. If the object was never added to the canvas, nothing happens and the method returns the core instance as usual.

Arguments

index : Number (since version 2.9.0)
The index of the object in the children list.
redraw : Boolean (since version 2.9.0)
If set to false, the canvas will not be redrawn right after the object is added to canvas. Can be used if you are adding lots of objects at the same time, but only want to redraw once when it's done.

Return Value

Core. Returns the core instance itself.

Examples

Example 1

We create three rectangles and add them to the canvas. Then we remove the second rectangle.

View Example
Code
var canvas = oCanvas.create({
	canvas: "#canvas"
});

var rectangle1 = canvas.display.rectangle({
	x: 27,
	y: 74,
	width: 200,
	height: 100,
	fill: "red"
});

var rectangle2 = canvas.display.rectangle({
	x: 67,
	y: 84,
	width: 200,
	height: 100,
	fill: "blue"
});

var rectangle3 = canvas.display.rectangle({
	x: 107,
	y: 94,
	width: 200,
	height: 100,
	fill: "lime"
});

canvas.addChild(rectangle1);
canvas.addChild(rectangle2);
canvas.addChild(rectangle3);
canvas.removeChildAt(1);
Output