addChild()

Add the passed in object to the canvas.

Syntax addChild(object [, redraw])

Return Type Core

Description

Add the passed in object to the canvas. This will immediately trigger a redraw of everything unless specified otherwise.

Arguments

object : displayObject
An object that inherits from the base displayObject. This could be either a predefined display object, or a user-defined created with the register() method.
redraw : Boolean (since version 2.0.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

First we create an instance of the core object. Then we create a display object, and finally we add it to the canvas.

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

var rectangle = canvas.display.rectangle({
	x: 77,
	y: 74,
	width: 200,
	height: 100,
	fill: "#000"
});

canvas.addChild(rectangle);
Output