Manish - Thanks - but that doesn't work for my situation.
I'm trying to add the color during the process of building a string that will be pulled into a textArea. Something like the following (doesn't work, but shows you what I'm trying to do): <?xml version="1.0"?> <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" xmlns="*" creationComplete=""> <mx:Text id="t" text="start" /> <mx:Button label="Color" click="createText()"/> <mx:Script> function doRed(text):String { var tf = new TextFormat(); tf.color = 0xFF0000; text.setTextFormat(tf); return text; } function doBlack(text):String { var tf = new TextFormat(); tf.color = 0x000000; text.setTextFormat(tf); return text; } function createText():Void { var textA = "Terrific vs. "; var textB = "Not so good"; textA = doRed(textA); textB = doBlack(textB); t.text = textA+textB; } </mx:Script> </mx:Application> At 09:19 PM 4/12/2005, you wrote: > > I'm building strings for display in a textArea. Is there a way to > > programmatically add color to selected portions of text? > >Yup. > ><?xml version="1.0"?> ><mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" > xmlns="*" creationComplete=""> > <mx:Text id="t" text="The quick brown fox jumped over the text." /> > <mx:Button label="Color" click="doColor()"/> > <mx:Script> > function doColor():Void > { > var tf = t.labelField.getTextFormat(5, 10); > tf.color = 0xFF0000; > t.labelField.setTextFormat(5, 10, tf); > } > </mx:Script> ></mx:Application> > >labelField is an undocumented property. It's of type TextField. Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/