# setFocus on first field - can't do it!

**URL:** <https://forum.kirupa.com/t/setfocus-on-first-field-cant-do-it/284260>\
**Category:** flash\
**Created:** [March 17, 2009, 11:17am UTC](https://forum.kirupa.com/t/setfocus-on-first-field-cant-do-it/284260 "2009-03-17T11:17:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxelcat](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/maxelcat/32/2854_2.png) [@maxelcat](https://forum.kirupa.com/u/maxelcat)\
**Post date:** [March 17, 2009, 11:17am UTC](https://forum.kirupa.com/t/setfocus-on-first-field-cant-do-it/284260/1 "2009-03-17T11:17:35Z")

</div>

Hi

I have a small form that for which the fields are created dynmically. I can’t seem to get the focus to set on the first field.

Can someone please advise.

Many thanks

```auto
var form_fmt:TextFormat = new TextFormat(); 
form_fmt.size = 13;
form_ftm.multiline=true;
form_fmt.font = "Trebuchet MS";

var fieldNames:Array = new Array("fullName","phone","email","ask");
for (var i:Number=0;i<4;i++){
 this.createTextField(fieldNames*,this.getNextHighestDepth(),100,10+i*30,200,22);
 if (i==0){
  setFocus("fullName");
 }
 
 if (i==3){//set up the text area
  ask._x=15; ask._y=160; ask._width=350; ask._height=88;
  ask.multiline=true;
  
 }
  eval(fieldNames*).type="input";
:
:
 
 
 eval(fieldNames*).onSetFocus = function():Void{
  this.backgroundColor=0xffffb3;//0xecf1f4;
  this.textColor=0x3f5465;
 }
 eval(fieldNames*).onKillFocus = function():Void{
  this.backgroundColor=0xffffff;
  this.textColor=0x333333;
 }
            
}

```
