as question
- Started
- Last post
- 7 Responses
- ozhanlion
I am trying to pass the textfield name as an argument in a function like so;
function foo(textfieldname) {
trace(_mc.textfieldname) //gives me undefined
}how can I reference this textfield?
- rabattski0
it's instance._name which gives you the name of the instance. if that's what you're after.
- ozhanlion0
nope I am after another thingy.
function foo(arg) {
arg.text = "yes";
}
foo(my_txt);this gives me the result I want, I want to pass the name of the textfield as an argument, this works but if I put this textfield in a mc it don't work..
like;function foo(arg) {
mc.arg.text = "yes";
}
foo(my_txt);//this is no go.
- ozhanlion0
function foo(arg) {
_mc = mymc;
trace(_mc.arg);
me = eval(_mc+"."+arg);
me.text = "am";
}
foo("my_txt");did the trick
- rabattski0
oooh ok. now i get it. i think. but _mc[arg] should work as well then (is the proper syntax if i'm not mistaken).
- Anarchitect0
rabattski is correct.
- ozhanlion0
yep it is working as well. I always prefer array notation, and hate that eval() function so thank you very much.
- rabattski0
cool!