# Help with setFocus, please!

**URL:** <https://forum.kirupa.com/t/help-with-setfocus-please/267529>\
**Category:** Uncategorized\
**Created:** [August 2, 2008, 6:11am UTC](https://forum.kirupa.com/t/help-with-setfocus-please/267529 "2008-08-02T06:11:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jewelee](https://avatars.discourse-cdn.com/v4/letter/j/8e7dd6/32.png) [@jewelee](https://forum.kirupa.com/u/jewelee)\
**Post date:** [August 2, 2008, 6:11am UTC](https://forum.kirupa.com/t/help-with-setfocus-please/267529/1 "2008-08-02T06:11:13Z")

</div>

Hello;  
I have a login page with 2 text boxes for user name and password, and a submit button.  
All I want is to have the flashing cursor show up in the user name text area. The instance name for this is tUsername. It is in a movie clip called start. Below I am pasting the working login code, then most of the things I have tried with setFocus, help would be greatly appreciated, and thank you!

//the code below works fine  
tError.autoSize = “right”;

\_global.lvSend = new LoadVars();  
\_global.lvReceive = new LoadVars();

mcLogin.onRelease = function() {

```
lvSend.username = tUsername.text;
//Selection.setFocus(tUsername);

lvSend.password = tPassword.text;
lvSend.sendAndLoad("logincheck.php", lvReceive, "POST");

```

};

lvReceive.onLoad = function(success:Boolean) {  
if (success) {  
if (this.login == “success”) {  
gotoAndPlay(“box\_open”);  
}else{  
tError.text = “I’m sorry you did not enter valid login details”;  
}  
} else {  
trace(“no reponse from server”);  
}  
};  
\_root.start.tUsername.selection.setFocus();

stop();

Here are some of the things I have tried so far above the onRelease function:

/\*tUsername is the instance name of the text box

Selection.setFocus(\_root.start.tUsername);  
another try, with and without double quotes  
Selection.setFocus(tUsername);  
and  
setFocus(\_root.start.tUsername);  
setFocus("\_root.start.tUsername");  
and again

Selection.setFocus(targetPath(this)+".tUsername");  
Selection.setFocus(Selection.getFocus());  
tUsername.onKillFocus = function() {  
trace(Selection.getFocus());  
trace(\_name+"\_root.start.tUsername");  
Selection.setFocus("\_root.start.tUsername");  
}

if (this.tUsername.text !=null){  
Selection.setFocus("\_root.start.tUsername")  
};

\_root.start.tUsername.selection.setFocus();

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/
