all groups > flash actionscript > december 2004 >
You're in the

flash actionscript

group:

Reference a passed textfield reference in a function?



Reference a passed textfield reference in a function? Wolli World
12/15/2004 10:25:21 PM
flash actionscript: Hi, I have a little typewriter function where I pass in a reference to a
textfield as shown below. I'm going to add this movie in another movie and
don't want to use an absolute path. Can anyone tell me how to relatively
reference the textfield variable? Thanks!

qa_txt is the variable name of a dynamic textfield created in the frame.

typewriter("qa_txt", qatxt, 24, 0);

function typewriter(txtfield, msg, chars, skp)
{
_root[txtfield] = (msg.substr(0, nextChar + skp) + "_"); // why does this
statement work?
this[txtfield] = (msg.substr(0, nextChar + skp) + "_"); // and this
doesn't? how do reference this?

other code...
};
Re: Reference a passed in textfield in a function? jerome NO[at]SPAM STC
12/15/2004 11:01:55 PM
if you don't want the function to worry about where the textfield is you should
pass a reference to the textfield in the arguments:

typewriter(this.qa_txt, qatxt, 24, 0);

function typewriter(txtfield, msg, chars, skp)
{
txtfield.text = ....
};

does that make sense?...
AddThis Social Bookmark Button