A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: How to change SelectionColor in TLFTextFielfd ?

  1. #1
    Junior Member
    Join Date
    May 2008
    Location
    new delhi, india
    Posts
    3

    How to change SelectionColor in TLFTextFielfd ?

    How to change SelectionColor in TLFTextFielfd created with var txtTest:TLFTextFielfd = new TLFTextFielfd(); syntax ?

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    I am not sure if that is what you mean. Select a text part and it will change the color when the mouse is up.


    import fl.text.TLFTextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;
    import flash.events.MouseEvent;

    var redFmt:TextFormat = new TextFormat();
    redFmt.color = 0xFF0000;


    var tlfText:TLFTextField = new TLFTextField();
    tlfText.border = true;
    tlfText.text = "You change the selectioncolor with textformat.";
    tlfText.wordWrap = true;
    tlfText.autoSize = TextFieldAutoSize.LEFT;
    tlfText.x = 100;
    tlfText.y = 100;
    tlfText.addEventListener(MouseEvent.MOUSE_DOWN, downHandler);
    tlfText.addEventListener(MouseEvent.MOUSE_UP, upHandler);
    trace(tlfText.selectionBeginIndex);
    addChild(tlfText);

    var begIndex:int;
    var endIndex:int;
    function downHandler(event:MouseEvent):void
    {
    begIndex = event.currentTarget.selectionBeginIndex as int;
    }

    function upHandler(event:MouseEvent):void
    {
    endIndex = event.currentTarget.selectionEndIndex as int;
    tlfText.setTextFormat(redFmt, begIndex, endIndex);
    }
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Junior Member
    Join Date
    May 2008
    Location
    new delhi, india
    Posts
    3
    When you select a porsion of a TLFextfield using setSelection method there are two color, first is text color and other is selected portion background color. In am talking about that selected background color part of the TLFextfield.

  4. #4
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    You cannot change the Selectioncolor unless you use workarounds. Here are workarounds for a regular textfield.

    http://yourpalmark.com/2007/08/13/ch...ic-textfields/
    http://labs.hellokeita.com/2007/11/1...ter-the-trick/
    - The right of the People to create Flash movies shall not be infringed. -

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