Why is this text field tracing "undefined"?

Please help me kirupians!

when i run:

var headerTxt:TextField = this.createTextField(header_txt,0,200,150,550,20);
trace(headerTxt);

it traces:

_level0.undefined

why would it do this? When I refer to headerTxt in code, i can set its format, properties and populate it with text, no problem. Yet it traces as undefined, and this is (im assuming) giving me a problem with removing the textfield from another function…

EDIT: ok, i solved my issues by just scoping the vars for the txt fields outside of the functions… but still, why is it tracing undefined???