# Problems using "Selection.getFocus()” method"

**URL:** <https://forum.kirupa.com/t/problems-using-selection-getfocus-method/120164>\
**Category:** Uncategorized\
**Created:** [August 21, 2004, 12:31pm UTC](https://forum.kirupa.com/t/problems-using-selection-getfocus-method/120164 "2004-08-21T12:31:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pup\_100](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@Pup\_100](https://forum.kirupa.com/u/Pup_100)\
**Post date:** [August 21, 2004, 12:31pm UTC](https://forum.kirupa.com/t/problems-using-selection-getfocus-method/120164/1 "2004-08-21T12:31:42Z")

</div>

[font=Times New Roman]I’ve been having a bit of trouble using the “Selection Object”[/font]

[font=Times New Roman] [/font]

[font=Times New Roman]What I don’t get is when using the “Selection.getFocus()” method, unless you create a movie with a lot of frames, say 60, the user will not have time to select a field for the method to report back on.[/font]

[font=Times New Roman] [/font]

[font=Times New Roman]I have tried the following script in the first frame[/font]

[font=Times New Roman] [/font]

[font=Times New Roman]stop();[/font]

[font=Times New Roman]eval(Selection.getFocus()).text=“Goat”;[/font]

[font=Times New Roman] [/font]

[font=Times New Roman]but because when the movie started playing no field had focus & Flash reports this back –nothing happens when I click into a field.[/font]

[font=Times New Roman] [/font]

[font=Times New Roman]Basically what I’m after is a way to stall Flash until a field is selected.[/font]

[font=Times New Roman] [/font]

[font=‘Times New Roman’]I have got round this by using the “onSetFocus” Listener, but can’t see the point of the other methods if flash will not give them time to trigger?[/font]

---

<div class="post-metadata">

**Author:** ![claudio](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@claudio](https://forum.kirupa.com/u/claudio)\
**Post date:** [August 21, 2004, 5:57pm UTC](https://forum.kirupa.com/t/problems-using-selection-getfocus-method/120164/2 "2004-08-21T17:57:58Z")

</div>

In this case you should indeed use the _onSetFocus_ handler, since you want to stall the movie until the user selects the textfield (which means you have to constantly check because you don’t know if it will take 1 frame, 5 frames, or even 100 fames to happen)  
The _Selection.getFocus()_ method applied on a frame will execute only once, when that frame is played. So if the user selects a textfield after that frame has been played, you won’t get the desired result.

---

<div class="post-metadata">

**Author:** ![Pup\_100](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@Pup\_100](https://forum.kirupa.com/u/Pup_100)\
**Post date:** [August 21, 2004, 8:02pm UTC](https://forum.kirupa.com/t/problems-using-selection-getfocus-method/120164/3 "2004-08-21T20:02:11Z")

</div>

Thank you very much claudio for such a concise & helpful reply

---

<div class="post-metadata">

**Author:** ![claudio](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@claudio](https://forum.kirupa.com/u/claudio)\
**Post date:** [August 21, 2004, 8:13pm UTC](https://forum.kirupa.com/t/problems-using-selection-getfocus-method/120164/4 "2004-08-21T20:13:00Z")

</div>

You’re welcome 🙂
