Skip to main content
Inspiring
February 21, 2007
Answered

TextField not displayed [AS 3.0]

  • February 21, 2007
  • 3 replies
  • 421 views
Hi I downloaded and installed The Flash 9 authoring tool to learn AS 3.0.
I tried the following sample in attachment. I have taken this sample from livedocs AS 3.0 flash.text.TextField help file.

I Created the as file and saved the files as TextField_alwaysShowSelection.as
Then i created fla file and saved in the same folder as TextField_alwaysShowSelection.fla
In flash file i created the instance
var tf:TextField_alwaysShowSelection = new TextField_alwaysShowSelection();

No errors nothing but textfield didnot show up.
I tried putting up trace after
label1.alwaysShowSelection = true;

trace(label1.text + " - " + label1.x + " - " + label1.y)

It shows the correct values i tried visible property and a lot of other things like using border property the values return are correct but textfield is not displayed..

Can anyone help me solving this...
This topic has been closed for replies.
Correct answer Peter Lorent
Yes, that's mentioned in the doc's.
The thing with your posted code is that when you set the Document class you are in fact extending the _root (which wasn't possible in AS2) and consequently the code 'knows' what you mean with addChild() - add the TextField to the display list of the _root.
If you want to create an instance of the TextField_alwaysShowSelection class on the timeline you (like in AS2) have to provide a target movieclip (or rather 'display object') where the TextField has to be displayed.
var tf:TextField_alwaysShowSelection = new TextField_alwaysShowSelection(this);
and the class as attached. But, you should always init an app with a Document Class.

3 replies

Inspiring
February 21, 2007
Thanks for the explanation.
Inspiring
February 21, 2007
Oh...
Thanks for the reply..
I will try it..
Also is this mentioned somewhere..in the docs/help??
Peter LorentCorrect answer
Inspiring
February 21, 2007
Yes, that's mentioned in the doc's.
The thing with your posted code is that when you set the Document class you are in fact extending the _root (which wasn't possible in AS2) and consequently the code 'knows' what you mean with addChild() - add the TextField to the display list of the _root.
If you want to create an instance of the TextField_alwaysShowSelection class on the timeline you (like in AS2) have to provide a target movieclip (or rather 'display object') where the TextField has to be displayed.
var tf:TextField_alwaysShowSelection = new TextField_alwaysShowSelection(this);
and the class as attached. But, you should always init an app with a Document Class.
Inspiring
February 21, 2007
>>In flash file i created the instance
>>var tf:TextField_alwaysShowSelection = new TextField_alwaysShowSelection();

The code you posted is to be set as the document class. There are two ways to do this:
-in the fla in the Property Inspector -> option 'Document Class' -> TextField_alwaysShowSelection
-in the fla File -> Publish Settings -> tab Flash -> ActionScript 3.0 option Settings -> Document Class -> TextField_alwaysShowSelection