Title: Loading mxml Components

p.s. tried doLater as well. No go

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Stacy Young
Sent: Tuesday, August 02, 2005 10:01 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] setFocus is evil

 

Semi-pseudo code…I’ve attached two pics, before and after to highlight what’s going on…even if I explicitly call setSelection using the text length to determine positions…it’s referencing the previous text value so calculations are wrong.

 

 

 

 

 

 

 

function initialize()

        {

            name.text = ModelLocator.field.languageDetails[0].label;

            Selection.setFocus(formItem);

        }

       

            ]]>

    </mx:Script>

   

    <mx:Text id="name" width="100%" autoSize="true" styleName="fieldName" />

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Stacy Young
Sent: Tuesday, August 02, 2005 9:49 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] setFocus is evil

 

This was first thing I tried…it doesn’t work properly because the text length it determines is that of the previous text. The textinput is bound to a data model…the model changes, then setFocus is called. (as well as setSelection or any other things I’ve tried)

 

-Stace

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of JesterXL
Sent: Tuesday, August 02, 2005 12:51 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] setFocus is evil

 

Old skool way was to use the text name.  You can use the built in setFocus, which originally was just a wrapper to Selection.setFocus.

 

As for setSelection:

 

Selection.setSelection(0, myText_txt.length);

 

That always has to occur after setFocus, not before.

 

----- Original Message -----

Sent: Monday, August 01, 2005 11:03 PM

Subject: RE: [flexcoders] setFocus is evil

 

Ok got it.  You have to use the selection object.  Here is the code (Straight from Flash MX 204 LiveDocs http://livedocs.macromedia.com/flash/mx2004/main_7_2/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Flash_MX_2004&file=00001659.html ) :

 

this.createTextField("myText_txt", 99, 10, 10, 200, 30);

myText_txt.text = "this is my text";

Selection.setFocus("myText_txt");

Selection.setSelection(0, 3);

 

Hope this helps J

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Mercer, Dustin
Sent: Monday, August 01, 2005 7:54 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] setFocus is evil

 

Stacy,

 

I have had this problem as well L  I am sad to say, I hate the focus manager.  Ok that was a little harsh… but none the less, it has its’ issues.  There is a way to set the position of the caret though (Set the start index of the caret as well as the end, so you can choose the text you wish to be highlighted).  I am going to try to find that code.  In the mean time, you may want to try setFocus in the show event or childrenCreated event.  That may fix your issue.  If not, then the code for setting the caret position may help.  I will find that code and post it.  Give me a few…

 

Dustin Mercer

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Stacy Young
Sent: Monday, August 01, 2005 7:03 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] setFocus is evil

 

Tiny problem but it’s still driving me nuts. I’ve got a viewstack that’s changed based on a users selection. Each time a container within that stack is viewed an initialization script is run to populate form elements. At the end of the process I’m using setFocus to, well, focus on the first textinput field. The problem is the selection on the textinput field is the length of the previous value for that field. So if the current value of the textinput is “abc” and the model changes to “abcdef”…When the setFocus executes it’s only highlighting from a to c

 

Hope that was clear, ‘tis late…

 

Thx

Stace

 






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Computer software testing Macromedia flex Development
Software developer


YAHOO! GROUPS LINKS




Reply via email to