Skip to main content
Aaronius9er9er
Inspiring
April 23, 2010
Question

Setting unfocusedSelectionFormat doesn't work when expected

  • April 23, 2010
  • 1 reply
  • 1778 views

I'm trying to set the unfocusedSelectionFormat so that when the text flow container loses focus the text stays selected (the range alpha remains at 1).

This works:

textFlow = new TextFlow();
Configuration(textFlow.configuration).unfocusedSelectionFormat = new SelectionFormat(0xffffff, 1, BlendMode.DIFFERENCE, 0xffffff, 0);

This doesn't:

var config:Configuration = Configuration(TextFlow.defaultConfiguration).clone();
config.unfocusedSelectionFormat = new SelectionFormat(0xffffff, 1, BlendMode.DIFFERENCE, 0xffffff, 0);
textFlow = new TextFlow(config);

Am I missing something?  It seems like the second way should work too.

This topic has been closed for replies.

1 reply

Adobe Employee
April 26, 2010

I find that your second example, where you make a clone of the Configuration and pass it to the TextFlow constructor is working. The first example is not, and that because changing the configuration of a TextFlow after its been constructed doesn't work -- the Configuration is essentially a way to initialize the TextFlow, but we don't support changing all the values after the TextFlow is constructed.

So, this works:

var config:Configuration = Configuration(TextFlow.defaultConfiguration).clone();

config.unfocusedSelectionFormat = new SelectionFormat(0xffff00, 1, BlendMode.DIFFERENCE, 0xffff00, 0);

var textFlow:TextFlow = TextConverter.importToFlow("Hello", TextConverter.PLAIN_TEXT_FORMAT, config);

And this doesn't:
var textFlow2:TextFlow = TextConverter.importToFlow("Hello", TextConverter.PLAIN_TEXT_FORMAT);
Configuration(textFlow.configuration).unfocusedSelectionFormat = new SelectionFormat(0xffff00, 1, BlendMode.DIFFERENCE, 0xffff00, 0);
And that is as expected.
Hope this helps,
- robin

Aaronius9er9er
Inspiring
April 26, 2010

That's what I was expecting, but I'm seeing the opposite.  My text container is within a custom UIComponent in Flex 3 if that makes any difference.  It doesn't matter a whole lot since I found a way that works, but if you want I can send you my examples.