Adding same child to Container twice gives error “Error #2006: The supplied index is out of bounds.”
I thought I would document this as I think the error message is rather unhelpful and even misleading. In Flex, say you add the same child DisplayObject to a Container:
// container is of type Container // child is of type DisplayObject container.addChild(child); container.addChild(child);
you get the error message “Error #2006: The supplied index is out of bounds.” That’s not a particularly helpful message, because it’s a very general error that is generated inside the Container.addChildAt() method; even though you are not explicitly defining a child index, the error is related to indexing of the array that holds children of the container. You would get the same error if you tried to use container.addChildAt() and specified an invalid index.
A better error message for this case would be something like “Duplicate child object not allowed in single instance of Container”.
