Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 08-21-2006, 04:55 PM   #1
csdstudio
Registered User
 
Join Date: Jun 2005
Posts: 145
Default How to set focus to a text field?

Now that setFocus() is gone, how do you tell the player to set focus to a specific input text field. I've searched thru the reference docs and haven't had any luck.
csdstudio is offline   Reply With Quote
Old 08-21-2006, 05:10 PM   #2
Tink
Addict
 
Tink's Avatar
 
Join Date: Nov 2001
Location: London
Posts: 2,128
Default

Code:
stage.focus = myTestField;
Tink is offline   Reply With Quote
Old 08-21-2006, 05:44 PM   #3
csdstudio
Registered User
 
Join Date: Jun 2005
Posts: 145
Default

Quote:
Originally Posted by Tink
Code:
stage.focus = myTestField;
Great, that was too simple. I always forget to check the Stage class. Thanks man!
csdstudio is offline   Reply With Quote
Old 08-21-2006, 05:47 PM   #4
csdstudio
Registered User
 
Join Date: Jun 2005
Posts: 145
Default

But how come when you set focus to the text field, the cursor isn't flashing yet you can still type?
csdstudio is offline   Reply With Quote
Old 08-22-2006, 05:23 PM   #5
Tink
Addict
 
Tink's Avatar
 
Join Date: Nov 2001
Location: London
Posts: 2,128
Default

Quote:
But how come when you set focus to the text field, the cursor isn't flashing yet you can still type?
good question which unfortunately I don't have the answer to
Tink is offline   Reply With Quote
Old 09-07-2006, 09:43 AM   #6
Mortimer Jazz
Thing
 
Mortimer Jazz's Avatar
 
Join Date: Jun 2001
Location: UK
Posts: 2,418
Default

Could this possibly be the same as in previous versions of Flash?

If your Flash Movie already has focus when you assign focus to a particularTextField then you will see the flashing caret, but if you set focus on a TextField during the initial setup (ie before the user has interacted with your Flash Movie in any way), your TextField will have focus, but the caret will not appear.

I seem to remember reading that this is a limitation they can't get around.
__________________
............................
FLEX/FLASH BLOG
Previous Flash Tutorials

............................
Mortimer Jazz is offline   Reply With Quote
Old 11-02-2008, 02:52 PM   #7
wojex
Registered User
 
Join Date: Nov 2008
Posts: 2
Default focus

You should use Selection object, especially setFocus method. It works great for me.

for example:

Selection.setFocus("_root.MyTextField");

Text indicator blinks and textfield is ready to edit.

regards
Wojtek Majerski
wojex is offline   Reply With Quote
Old 11-28-2008, 02:48 PM   #8
insomniac42
New Member
 
Join Date: Mar 2007
Posts: 29
Default

The Selection class no longer exists in AS3, but this will focus the text field and place the carat at the end:

ActionScript Code:
stage.focus = textField; textField.setSelection(textField.text.length,textField.text.length);
insomniac42 is offline   Reply With Quote
Old 12-10-2008, 08:08 PM   #9
bubba
Member
 
Join Date: Jun 2002
Location: arizona
Posts: 99
Default

What if you don't have any actual text in the field and just want the cursor to flash at position 0. The code doesn't seem to work.

Quote:
Originally Posted by insomniac42 View Post
The Selection class no longer exists in AS3, but this will focus the text field and place the carat at the end:

ActionScript Code:
stage.focus = textField; textField.setSelection(textField.text.length,textField.text.length);
bubba is offline   Reply With Quote
Old 12-10-2008, 08:28 PM   #10
bubba
Member
 
Join Date: Jun 2002
Location: arizona
Posts: 99
Default

Here's the solution if anyone needs it:

http://reality-sucks.blogspot.com/20...ing-focus.html
bubba is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help duplicating a dynamically loaded text field odobo ActionScript 2.0 1 10-06-2005 06:32 PM
Disable focus in a text field? lkelly ActionScript 2.0 2 12-16-2004 12:00 AM
Setting focus on text field within attached MC stevier ActionScript 2.0 1 12-15-2004 06:22 PM
set focus on text field womblies ActionScript 2.0 0 11-08-2004 10:12 AM
create text field and getbounds with actionscript eddyrkdn ActionScript 1.0 (and below) 1 07-08-2004 09:24 AM


All times are GMT. The time now is 10:32 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.