Skip to content

Instantly share code, notes, and snippets.

@stickupkid
Forked from claus/gist:456130
Created September 25, 2010 09:07
Show Gist options
  • Save stickupkid/596642 to your computer and use it in GitHub Desktop.
Save stickupkid/596642 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="utf-8"?>
<!-- Convert HTML to XML and use E4X to access DOM (AIR required) -->
<s:WindowedApplication
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="creationCompleteHandler(event)">
<fx:Script>
<![CDATA[
import com.codeazur.utils.XMLUtil;
import mx.events.FlexEvent;
protected function creationCompleteHandler(event:FlexEvent):void {
htmlControl.addEventListener(Event.COMPLETE, htmlCompleteHandler);
}
protected function htmlCompleteHandler(event:Event):void {
var x:XML = XMLUtil.jsDomToE4X(htmlControl.domWindow.document);
var ns:Namespace = Namespace("http://www.w3.org/1999/xhtml");
var embeds:XMLList = x..ns::embed.@src;
trace(embeds.toXMLString());
}
protected function loadButton_clickHandler(event:MouseEvent):void {
if(urlInput.text != "") {
htmlControl.location = urlInput.text;
}
}
]]>
</fx:Script>
<s:VGroup width="100%" height="100%">
<s:HGroup width="100%">
<s:TextInput id="urlInput" width="100%" text="http://www.spiegel.de/" />
<s:Button id="loadButton" label="load" click="loadButton_clickHandler(event)" />
</s:HGroup>
<mx:HTML id="htmlControl" width="100%" height="100%" />
</s:VGroup>
</s:WindowedApplication>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment