PDA

View Full Version : Creating an onload handler for TextFields


_tippedOver
01-21-2005, 07:58 PM
Is it possivble to create an onLoad handler for all textfields? I want all textfields to execute the same function when they appear on screen. Can I edit the Textfield class in some way?

Thanks
Andy

Xeef
01-21-2005, 09:31 PM
X = MovieClip.prototype.createTextField;
MovieClip.prototype.createTextField = function(Clip, Depth, x, y, h, w) {
X(Clip, Depth, x, y, h, w);
trace("Do somthing!");
};
this.createTextField("my_txt", 1, 100, 100, 300, 100);
my_txt.multiline = true;
my_txt.wordWrap = true;
var my_fmt:TextFormat = new TextFormat();
my_fmt.color = 0xFF0000;
my_fmt.underline = true;
my_txt.text = "This is my first test field object text.";
my_txt.setTextFormat(my_fmt);

_tippedOver
01-24-2005, 02:21 PM
I like it! It works well for TextFields added through ActionScript but what about TextFields added onto keyframe on the timeline? The project I'm working on was done by a desinger and totally timeline based. I'm trying to figure out an easy way of externalizing all the content and having TextFields basically go get their text from a central object.

Cheers
Andy