Dynamically add component question?


Here is part of my code in short:

public class TextInputWithAutoComplete extends TextInput

[INDENT]private function addComp():void{

list = new List();
list.id = "autoCompleteList";
list.x = 0;
list.y = 20;
list.addEventListener(MouseEvent.MOUSE_UP, handleMouseDown);

parentDocument.addChild(autoCompleteList); OR addChild(autoCompleteList); //my question is here


private function handleMouseDown():void{


I realized that if I do addChild, I can’t really see the dynamically added component, since flex did not reserve space for my List to display. So I do parentDocument.addChild, and then it appears no problem. My question is since it’s being added in the parentDocument, so it is suppose to be a component belong to parentDocument, so is that component still be able to call this handleMouseDown?

From my experience, it’s still able to, but which doesn’t make sense to me.

Can someone explain a little about why it can still work, or any better approach other than parentDocument.addChild