Reference button from within the function it calls?

I’m making a function to be called by different buttons, and I want the function also alter the appearance of the button itself. But I don’t know how to refer to the button from within the generic function.

function set_style() {
	trace('this: '+this);
	trace('_parent: '+_parent);
	trace('_root: '+_root);
	trace('_level0: '+_level0);
//none of these produce the name of the button
}
bt1.onRelease = function() {
	set_style();
	trace('[from button] this: '+this);
//this produces the name of the button
};

What makes that function generic?

Anyway, you can use:

set_style.apply(this);

Using apply allows you to select the scope in which the function is called. You could also pass a reference to the button into set_style.


function set_style(mc) {
mc = this;
	trace('this: '+this);
	trace('_parent: '+_parent);
	trace('_root: '+_root);
	trace('_level0: '+_level0);
//none of these produce the name of the button
}

bt1.onRelease = function() {
	set_style(this);
	trace('[from button] this: '+this);
//this produces the name of the button
};