View Source on Flex HTML Control
There are two ways to load content into Flex’s HTML control. The first is to set assign the
htmlText property some HTML. The second is to set the
location property to the URL of the site you wish to load. The two are mutually exclusive, as described in the ActionScript 3 Reference here.
htmlTextproperty: Setting this property has the side effect of setting the location property to null, and vice versa.
The implication of this is that if you load content via setting the
location property, you cannot use the
htmlText property to view the source HTML of the site you loaded– it will return null. So the question is, how do we do this?
window.document property of the HTMLLoader. So assume I have declared the following HTML control.
<mx:HTML id="html" location="http://www.googolflex.com" width="100%" height="100%" />
I could then view the loaded contents in a variety of ways. The HTMLLoader I mentioned previously is a member of the HTML control, and is conveniently named
var o : Object = html.htmlLoader.window.document.getElementsByTagName("html"); trace( o.textContent ); trace( o.innerText ); trace( o.innerHTML );