# Wait for user input in a function

**URL:** <https://forum.kirupa.com/t/wait-for-user-input-in-a-function/328475>\
**Category:** flash\
**Created:** [May 19, 2012, 6:47pm UTC](https://forum.kirupa.com/t/wait-for-user-input-in-a-function/328475 "2012-05-19T18:47:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tompa](https://avatars.discourse-cdn.com/v4/letter/t/6de8d8/32.png) [@Tompa](https://forum.kirupa.com/u/Tompa)\
**Post date:** [May 19, 2012, 6:47pm UTC](https://forum.kirupa.com/t/wait-for-user-input-in-a-function/328475/1 "2012-05-19T18:47:28Z")

</div>

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:

```auto
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_
