Moving focus of text fields

Greetings. I hope this is an easy question but have not found the command or any source code which illustrates how to do this.
I have a series of text fields in a window. I check each for length on changed, and would like to reassign focus to the next field when the current field reaches the correct length. Logic and experience with other languages tells me to use something like:

focus text field "theField" of window "Application"

Please let me know if there is a way to do this, as it is not apparent anywhere I’ve checked so far.

I think you can use “set first responder to …” (unchecked)

Nope…at least it didn’t work for me. I tried that earlier, and I get the error:

I am fairly new to AS, so perhaps my implementation may be wrong, but it seems fairly obvious that I might write:

set first responder to text field "textField" of window "application"

Someone please correct me if I’m wrong.

Thanks, though…jg

I’ve seen the dictionary, and “first responder” is a property of windows and panels (not the application). So, this is the syntax:

set first responder of window 1 to text field 1 of window 1

(substitute “1” with your own data)

Thanks jj

I kind of worked around that until I didn’t need it anymore. I figured recently that it was a problem with correctly identifying the object, as you mentioned. I’ll go back and make sure, and then use it in an upcoming application where I am already sure I’ll need it.

Thanks again,

jj is right about setting the current focus by setting the first responder property:

tell window "main"
    set first responder to text field "field name"
end tell