Maybe #initclip isn't supported in the main timeline
How I get your code to work is like this ...

Add a movieclip to the symbol library with link name SWR_Tree and add this part of the code to it's first frame.
Code:
#initclip

function SWR_Tree()
{
this.createTextField("tf",100,20,20,200,200);
this.tf.text="hello world";
}

SWR_Tree.prototype = new MovieClip();

Object.registerClass("SWR_Tree",SWR_Tree);

#endinitclip
Now add
Code:
attachMovie("SWR_Tree","tree", 101);
to the first frame of the main timeline.

That should do it.