removeChild()

Description

Remove the passed in child from the object. This will remove the child from the canvas as well.

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.6.0)

If set to false, the canvas will not be redrawn right after the object is removed from the canvas. Can be used if you are removing lots of objects at the same time, but only want to redraw once when it's done.

Return Value

displayObject. Returns the display object itself.

Examples

Example 1

We create a new core instance, a rectangle and a square. Then we add the rectangle to the canvas and add the square as a child to the rectangle. Finally we add an event handler that removes square when the rectangle is clicked.