Functions path

I am kinda puzzled as to where functions lay in path targeting. for example, lets day i have this code on the first frame of a blank .fla:

function pathTest() {
trace("it runs...")

and then of course on the stage i have a text field with a instance named atextfield. the function runs but does not work. If i take off the “this” then it works. Why? I was reading something about private and public functions the other day, does this have anything to do with this?

for the most part, ‘this’ is an identifier which references an object or a movie clip (though sometimes it can reference a timeline…look in flash’s reference panel for more on that).

but normally, when a script executes, ‘this’ references the movie clip instance that contains the script.

you’ve got your script on a frame so ‘this’ doesn’t reference anything – that’s why you’re getting an error. but then again you don’t need it to. you already point to what you want to change, i.e. ‘atextfield’ – and that’s enough.

i was surprised that your reference to “this” stopped the function working properly and i`ve just tested it and with flash mx it works as typed above.