Frames vs. External file

IS the code used for AS3 in the frames so much different from the code used in the external .as files? Because when I try something simple in an external file, it doesn’t work. For example, if I try to dynamically make textfield box, and set it to input :


var textInput:TextField = new TextField();
textInput.type = TextFieldType.INPUT;

I just get errors. Why is this? And is there some place I can find a guide for like… how to write in the external as files (even though that’s a very broad area…)