سؤال

Hoping to obtain the help of some Flex 3/4 gurus out there...

I am attempting to dynamically change the color of a subset/portion of text in a Spark TextArea control. Using the MX-based TextArea, I could leverage the mx.controls.textClasses.TextRange type and change the color directly as follows:

TextRange tr = new TextRange(theTextAreaControl, false, beginIndex, endIndex);  tr.color = somePredefindColor;

Input Parameters to TextRange constructor:

  1. 1st argument: The TextArea control that will provide access to the underlying textField property
  2. 2nd argument: Indicates the TextRange will not modify the content of the TextArea
  3. 3rd argument: The beginning index position in the TextArea text string
  4. 4th argument: The ending index position in the TextArea text string

How would I go about doing this for a Spark-based TextArea control? I am looking to dynamically change the font color for a range of text, not just the entire TextArea AND I cannot statically specify the font color. The problem I run into when trying to re-use the TextRange type is that the 1st argument is expected to provide the textField property, which is currently not on the Spark-based TextArea control. I thought about extending the Spark-based TextArea control to provide this accessor property but that seems like overkill and is probably not the best approach.

Any help would be greatly appreciated.

Thanks, Michael

هل كانت مفيدة؟

المحلول

When manipulating Spark text components, you'll want to use the Text Layout Framework (TLF), which is built on top of the Flash Text Engine (FTE) that was introduced in Flash Player 10. It gives you major control over how the text is displayed (at the cost of being pretty complex.) Here's a good place to start: Using Text Layout Framework

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top