Skip to main content
Participant
October 19, 2010
Question

Problem with runtime-created TextArea and setFormatOfRange

  • October 19, 2010
  • 1 reply
  • 587 views

I've got an application which, as it gets results back from a query, adds textarea's to a vgroup and displays them.

The vgroup vg exists at compilation, the summary textarea's do not.

I'm trying to add some kind of highlighting for the keywords that were used, and I'm having some trouble.  I've boiled it down to this:


var summary:TextArea = new TextArea();
summary
.text = "something"
var tlf:TextLayoutFormat = new TextLayoutFormat();
tlf
.fontSize = 18;
tlf
.fontWeight = "bold";
tlf
.color = 0xFF0000;
summary
.setFormatOfRange(tlf, 0, 2);
vg
.addElement(summary);

For some reason, even this won't work in the context of what I'm trying to do.  (this is a simplified version, I can get the code for the whole function this is running in if it'll help anyone).

Any ideas?  Is what I'm trying to do even possible?

This topic has been closed for replies.

1 reply

Participant
October 19, 2010

I found out something, this will work:

var vg:VGroup = new VGroup();

var l:Label = new Label();

var summary:spark.components.TextArea = new spark.components.TextArea();

var hb:HRule = new HRule();

summary.text = "Select some text and click the button to apply a bold/red style.";

vg.addElement(l);

vg.addElement(summary);

vg.addElement(hb);

resultsVGroup.addElement(summary);

var styleObj:TextLayoutFormat = new TextLayoutFormat();

styleObj.fontWeight = FontWeight.BOLD;

styleObj.color = 0xFF0000 + i*20; // red

summary.setFormatOfRange(styleObj,0,i+2);

But, if I call resultsVGroup.addElement(vg), it doesn't work.

Will putting the summary into another VGroup remove its formatting?

Adobe Employee
October 19, 2010

> Will putting the summary into another VGroup remove its formatting?

Don't see why it should.  Best to take these issues to a Flex forum

Richard