Wait for user input in a function

Hello again!
I’m having a problem with one of my functions that is supposed to return a String.
The function is checking if the user has been on the site before (using Shared Objects),
if it’s the first time the user visits, he will be asked to enter his nickname in a messagebox (a Movieclip with a textbox and a button), and here is the problem!

Here is the function:

public function checkNickname():String{            
    if(MySharedObject.data.Nickname == undefined){
        // First time user enters the site (or cleared his browser cache..)
        mc_nickReq.btn_done.addEventListener(MouseEvent.CLICK, buttonHandler);
        mc_nickReq.btn_done.stop();
        
        [COLOR=#b22222]Here is the problem!
        How do I know what the user entered in mc_nickReq **without **leaving this function?
        Something like this:
        
        While(User haven't entered his nickname){
            Keep on waiting..
        }[/COLOR]
    
         return* (the name the user entered)*
    }else{
        // User has been here before
        return MySharedObject.data.Nickname;
    }
}

I hope you understand where the problem is and what I mean :puzzle:
Thanks in advance,
Tompa