sanjay had a follow up question:
One of the things in my original query was to find out whether it is normal that the instance name of the button ("theButton") when used as a var/param will contain its target path.
For example, on the theButton, inside a mc mc1:
on (release) {
SomeFunction(theButton);
}
SomeFunction is on a frame in the mc (mc1) containing the button.
function SomeFunction(param1) {
trace(param1);
}
The trace is:
_level0.mc1.theButton
Is this to be expected?
colin answers:
=======================
hi again sanjay,
yes, that's the expected and normal output. here's why:
in your example, you have a button with an instance name "theButton" on a frame of a movie clip named "mc1". you attach the following code to your button:
on (release) {
SomeFunction(theButton);
}
as you can read on page 234-235 of asdg2, the scope of statements in an on() handler attached to a button is the movie clip that contains the button. you already intuitively knew that in your code because you referred to SomeFunction() directly by name, as though your code were on a frame of mc1. by extension, you also knew that you could refer to theButton directly when you passed it as an argument to SomeFunction().
your example statement:
SomeFunction(theButton);
passes a reference to the "theButton" object to the function "SomeFunction". inside that function, you display the reference in the Output panel:
trace(param1);
values passed to trace() are converted to the String datatype before being displayed in the Output panel. converting a Button object to a string yields the Button's target path (same as doing targetPath(theButton)). hence, the Output panel displays:
_level0.mc1.theButton
colin
ps. i know it's just an example, but you shouldn't start your function names with a capital letter. normally a leading capital letter is used only for class names.