Skip to main content
asidfree
Known Participant
October 23, 2006
Question

.as file createTextField problem

  • October 23, 2006
  • 4 replies
  • 350 views
Hello,

I'm working on an interactive map. The map has buildings on it, each building has a class attached to it (Buildings.as). The class has a function that creates a label (using createTextField)and places it over the building. The function is called createLabel and the textfield is called txt.

The problem I am having is when I compile the map in Flash, it complains at me each time I reference the txt I just created saying:
quote:

**Error** Buildings.as: Line 78: There is no property with the name 'txt'.

How do I get this to compile properly? I'm using Flash MX Pro 2004. Thanks.

(Attached is the Buildings.as file)
This topic has been closed for replies.

4 replies

Participating Frequently
October 23, 2006
try creating an empty movieclip then creat the textfield in that

var container:Movieclip = this.createEmptyMovieClip("container", this.getNextHighestDepth());
var txt:TextField = container.createTextField("txt", ..........);
then also get rid of with and hard code the formating
asidfree
asidfreeAuthor
Known Participant
October 23, 2006
I also tried changing lines 78 and on to:
quote:


//with(this.txt) {
//trace("This is the location: " + this.eval(this._name.toString()).txt);
this.txt.text = "" + this._name.toString();
this.txt.border = true;
this.txt.autoSize = true;
this.txt.setMyNewTextFormat(myFormat);
//}


This resulted in the same error as originally mentioned.
Participating Frequently
October 23, 2006
have you tried
with(txt) {
//
}
asidfree
asidfreeAuthor
Known Participant
October 23, 2006
Unfortunately, that didn't work. I got the above mentioned error, as well as this one:
quote:


Error: A 'with' action failed because the specified object did not exist.

Participating Frequently
October 23, 2006
what code is on lines 77-79:
asidfree
asidfreeAuthor
Known Participant
October 23, 2006
I had tried simplifying the .as file to keep the question less confusing.

The line that it's referring to is where it says:
quote:


78 with(this.txt) {
79 //trace("This is the location: " + this.eval(this._name.toString()).txt);
80 text = "" + this._name.toString();
81 border = true;
82 autoSize = true;
83 setMyNewTextFormat(myFormat);
84 }



Here is the file in it's entirety: