Reputation: 805
Is it possible that such simple thing isn't possible to change. I searched for this but couldn't find anything useful.
Upvotes: 1
Views: 2293
Reputation: 13
It's as simple as follows:
txtareaDisplay.setStyle("focusedTextSelectionColor", 0XFF0000);
in selectionChange
event of TextArea
. Try it.
Upvotes: 1
Reputation:
var textFormat:TextFormat = textField.getTextFormat();
textFormat.color = 0xFFFFFF // or whatever
textField.setTextFormat(textFormat, textField.selectionBeginIndex, selectionEndIndex);
That will change the color and pretty much whatever else you want in the area of the text field that is selected. Note that my code was just typed out off the top of my head so you're gonna have to double check spelling etc but that will work. For more see here:
Just as a note, flash text fields are pretty stupid when you're dealing with selection indexes. Both the very first and the very last index in the text field read as -1. So if you have a selection of text that goes from index N to the end of the text in the textField... the parameters for your setTextFormat will be: (textFormat, N, -1), which will throw a range error. You need to do some cleaver work to detect this type of scenario and work around it. One possible solution might be to check the selectionBeginIndex, then selectionEndIndex, check to see if either of them are equal to -1 and if so, act accordingly. For example, if selectionEndIndex is -1, then you'll want to cast a variable and set to textField.length - 1, so that you can use that variable as your second parameter and thus avoid the range error.
Upvotes: 1