Hi all. I’m was wondering how to modify my text in a textarea component such as fontsize, color and creating a hyperlink if possible.
I’m getting text via xml and sending the text to flash. I want to modify that text in the textarea.
I created an event listener for urlloader and I display the text with a function. Here’s my code, the comments show what I’d like to modify.
textLoader.addEventListener("complete", textLoaded);
function textLoaded(event:Event):void {
textXML = XML(textLoader.data);
//Larger font size, with a different color
itemText.text += textXML.item[0].product + "
";
//clickable link that opens browser window
itemText.text += textXML.item[0].link + "
";
}
If you want to change all the TextArea font properties within a TextArea component in AS3, you need to use the “setStyle()” method: http://snipplr.com/view/4099/as3-adding-styles-to-a-textarea-component-using-new-textformat/
Otherwise, enable HTML within the textarea and then mark up your text with the standard tags.
Hii, you can make use of htmlText here.
I havn’t did it in my work yet, but it should work.
Here is your code with some modification:
textLoader.addEventListener(“complete”, textLoaded);
function textLoaded(event:Event):void {
textXML = XML(textLoader.data);
//Larger font size, with a different color
itemText.text += textXML.item[0].product + "
“;
itemAnotherText.text += “<B><FONT COLOR=’#000000’>”+itemText.text+”</FONT><B>
";
//clickable link that opens browser window
itemText.text += textXML.item[0].link + "
“;
itemAnotherText.text += “<B><A …>”+itemText.text+”<B>
";
}
Where you should declare “itemAnotherText” as htmlText type.
Hope it 'll help you.
Thanks.