A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [CS2] setSelection help

  1. #1
    Senior Member Shotsy247's Avatar
    Join Date
    Apr 2001
    Location
    Be there in a minute!
    Posts
    1,386

    [CS2] setSelection help

    Hi All,

    I'm trying to automatically select all of the text within a textfield when a user selects that field. How can this be done?

    What I have tried is:

    Code:
    myText.onSetFocus = function(){
    	Selection.setFocus(this);
    	Selection.setSelection(0,999);
    	//Also tried Selection.setSelection(0);
    	//And Selection.setSelection();
    }
    But it's not working. What am I doing wrong?

    Thanks.

    _t
    I don't feel tardy.

  2. #2
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    "I" believe it to be a loading problem.. tings need time to fully load and instantiate before they can be really manipulated/controlled.

    or maybe the text field being re-drawn or something?

    looking at the AS Docs.. they use an onEnterFrame to set it and delete it n the same function.. and it works..


    I try from a button..and it highlights/selects for a second..then goes away as if something is clearing it.

  3. #3
    Senior Member Shotsy247's Avatar
    Join Date
    Apr 2001
    Location
    Be there in a minute!
    Posts
    1,386
    Thanks Whispers.

    I ended up firing the code from an invisible MC that I placed over the textField.

    code:
    invisiBut.userHandCursor = false;
    invisiBut.tabEnabled = false;
    invisiBut.onRelease = function(){
    Selection.setFocus(this._parent.myText);
    Selection.setSelection();
    }



    Not pretty, but it works.

    _t
    I don't feel tardy.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center