PDA

View Full Version : using mc vars in function?



blackpulp
August 16th, 2003, 06:16 PM
ok, first of all, im not totally sure how to describe my problem so im going to recreate a simple example of what im trying to do...

my problem is that im not sure how to refer to a dynamic mc in a function...i know that sounds confusing but maybe this will help...

lets say i have a function like:

fakeFunction = function (mcName){
// refer to the dynamically targeted mc
_root.mcName._x = 123;
}

the problem with this is that the function looks for an mc titled "mcName"...and the function is hard coded...what i want to do....is to reuse this function with any movieClip on the timeline i want...so how do i refer to the mc in the function dynamically? i hope this makes sense?

ive also tried something like this

_root[mcName]_x = 123;

but this doesnt work either....ive seen something like this done before...using brackets to target an mc with a var...

any help would be much appreciated...

blessings.

senocular
August 16th, 2003, 06:27 PM
take a look at this
http://www.kirupaforum.com/forums/showthread.php?s=&threadid=12082
it should help