AS3 HTML Parser Library:
This project is an AS3 HTML parser and renderer to replace the simple htmlString support in some elements. Compatible with Flex 3, written using the MPL version of the Flex 3 SDK. The parser is simple and expects limited HTML errors. The renderer mocks the presentation of Firefox 3 but allows for each element type's rendering to be overridden. The project is self-contained (requires nothing but the Flex 3 SDK to compile). It currently supports most elements (including img, span, div) and is approximately 70% accurate with more changes to come.
The project is offered free under the BSD license though donations are encouraged.
This project is intended for SWF web applications. People building AIR applications can use this project or the built-in HTML facilities.
Why this project over others?
1. This project contains an HTML parser:
Other projects rely on AS3 XML parsing facilities which works for XHTML but won't work for code such as (because the img tag is not closed according to XML parsers):
<div><img src="test.jpg"><input type=checkbox checked></div>
This also means this project can accept HTML output directly for WYSIWYG editors such as FCK
. In fact, the project was built around this use case.
2. This project uses 100% flash:
3. The license:
This project is offered 100% free for all uses. Simply maintain the authorship messages in each file.
This project only adds ~30KB to a compiled SWF file.
Parsing: Simple html fragments (about 10 elements) parses in ~6ms. Larger HTML fragments (containing 100 or more elements) parses in ~50ms.
Rendering: Simple html fragments (about 10 elements) renders in ~60ms. Larger HTML fragments (containing 100 or more elements) parses in ~250ms.
Sample Usage (see TestApp's main.mxml here
for more information):
var e:Element = HtmlParser.parse(htmlString);
var o:UIComponent = FlashHtmlRenderer.render(e);
if (o == null)
Alert.show("Unable to render html");
//Assume container is an element on the page
Using this project or looking for new features? Support this Project with a small donation: