Textfield variable name

I have 3 textfields, and an eventlistener for each textfield which looks like this:


var currentSelectedTextfield:String = "textfield1";
mc1.mc2.textfield1.addEventListener(FocusEvent.FOCUS_IN, handleFocusIn);
mc1.mc2.textfield2.addEventListener(FocusEvent.FOCUS_IN, handleFocusIn);
mc1.mc2.textfield3.addEventListener(FocusEvent.FOCUS_IN, handleFocusIn);

function handleFocusIn(e:Event) {
    currentSelectedTextfield = e.currentTarget.name;
}

The thing I want to do is using “currentSelectedTextfield” variable in another function like this:


function addLetter(myWord:String):Function {
    return function():void {
        switch(myWord) {
            default:
                myWord = myWord;
                break;
        }
        mc1.mc2.currentSelectedTextfield.appendText(myWord);
        
}

But this obviously isn’t working, any ideas? :slight_smile: