Microsoft Word - 200508_VersaLaser_Section_3_English:: that you specify in the VersaLASER Settings popup (explained later) set focus manually by using the included Focus Tool (also explained later) http://www.science.smith.edu/resources/cdf/pdf_files/versaLaser Operation.pdfHOME | Ok, I recently just needed to use setFocus() and I searched the forums and was confused as 90% of the people posting were as to why it wasn't working.
Here are some tips, guidelines and do's and donts to ensure your setFocus will work smoothly.
Usage
// returns currently focused instancename:String
Selection.getFocus();
// returns true or false if setFocus was successfull Sony Cyber-shot DSC-W170 Digital Camera - Review - The Imaging Resource!:: (which you can turn off) that explains functions and settings by displaying a manual focus option, which lets you set focus to half a meter, a meter, three http://www.imaging-resource.com/PRODS/W170/W170A.HTMHOME | HOW TO: Automatically Detect If a Form Is Being Edited in Access 2000:: NOTE: This article explains a technique demonstrated in the sample file, FrmSmp00.mdb. If bFlag Then Me!FirstName.SetFocus Me!btnUndo.Enabled = False bFlag http://support.microsoft.com/kb/210334HOME |
Selection.setFocus(instancename:String);
The help documents state for instancename:String the following.
You can use a relative or absolute path.
This is incorrect to my tests, I tried using relative pathing such as "containerMc.textInstanceName" it simply would not work.
Selection is a _root function, it's going to try and basically do
Selection.setfocus(_root.instancename)
Hence if you used a relative pathing from a class/movieclip it will not work.
Workaround #1)
you can always use direct pathing using _root
Selection.setFocus("_root.mc1.mc2.textInstanceName");
This works great if you are not loading swfs with form fields. However, like always _root is very very bad to use if you're loading the swf into another one because the _root will go to the parent swf's _root and mess things up. So the next question is, how do we get a relative path to a absolute path?
Workaround #2)
Below is an actionscript snippet that will get the current dot notation root path and set the focus.
Selection.setFocus(targetPath(this)+".instanceName");
Make sure you put a . before putting the instance name, the instance name should be a path with dot notation so if you're text field is inside a movie clip it should be ".mcinstancename.textfieldinstancename"
Feel free to ask questions you have regarding this matter, hope this will help everyone understand this "setFocus()" a bit better. How to Trap VB Form Lost Focus with GetActiveWindow API:: API function GetActiveWindow in a Visual Basic timer event, as explained below. You must set FOCUS=TRUE in the Click event procedure of every control http://support.microsoft.com/kb/69792HOME | The BalusC Code: Set focus and highlight in JSF:: I believe that a best way to set focus on first input would be inserting a HTML Doctype explained. LinkedIn. Followers (9) Follow this blog. Stop following http://balusc.blogspot.com/2007/12/set-focus-in-jsf.htmlHOME |
Edit, I forgot F.A.Q.
Q: The setFocus is tracing back as true but it's still not focusing the text field what gives?
A: Check to make sure the setFocus was the very last action called to after any button presses or what not. If you setFocus then the user cicks a button the button will take focus over. To help debug try putting a
instanceName.onKillFocus = function() {
trace(Selection.getFocus());
trace(_name+" :: Lost Focus");
}
It will trace what object and it's path that took over focus. If you pressed a button sometimes it will retain the focus but not be "focused for text input". This is a weird bug or just how flash works. To return focus at the very last code running on the button actions simply put
Selection.setFocus(Selection.getFocus());
Q: Can I use a variable instead of an instance name for a text field?
A: I've never used variable names for text fields, I much rather use instanceName for control purposes, if you're loading vars just run a function to set .text or you can always use different variable names than the instance name
I'm posting an example in a few minutes, bear with me!
Flaevo,
InputTF on the second frame. I want the InputTF to have focus when the frame enters. I've tried your methods, but none seem to work. It seems like a pretty simple function. Alas, I cannot seem to find the simple solution. thanks so much.
PS I was directed here.
Red Hat's Rough Recovery From CFO Exit
Windows Live Finds a New, Pre-installed Home |