Using html links in flex with xml data

So I'm not sure why this took me so long to figure out since it's actually quite simple...

I have a flex application that is pulling all its data from an xml file. I wanted to add links to certain pieces of text. I finally figured out a way to make it work... if this is the best way or not, I do not know, but it works! (This is why I'm not a programmer... haha).

Use a combination of xml file with node wrapped in the ![CDATA[ tag, Text component, and the htmlText property.

Example:

MXML snip:


<mx:HTTPService
id="contentService"
url="assets/xml/content.xml"
resultFormat="e4x"
result="contentResultHandler(event)"
fault="contentFaultHandler(event)"/ >


ActionScript:
iText = new Text();
iText.htmlText = xmlListColl.getItemAt(n).writeup;


XML snip:

<section>
<title>my writeup </title >
<writeup>
<![CDATA[Here is a <font style="color:'#0000FF';"> <a href="'http://www.mylinkaddress.com'" target="'_blank'">LINK </a > </font > that shows up blue and is clickable and opens the link in a new browser window.]] >
</writeup >
</section >


YAY :)

Comments

Popular posts from this blog

Flex Advanced Data Grid collapses on refresh

Add and remove lineseries - Flex LineChart