HTML

Kind of class:public class
Package:HTML
Inherits from:Sprite
Author:Tyler Larson
Classpath:HTML
File last modified:Monday, 26 October 2009, 10:10:03
A simple HTML and CSS parser
@langversion ActionScript 3@playerversion Flash 9.0.0
Since:
  • 24.10.2009

Summary


Constructor
  • HTML (width:int, height:int)
Instance properties
  • styleSheet (styles:String) : String
    • A CSS Stylesheet can be set here and used to style your HTML nodes
  • innerHTML (html:String) : String
    • Set the HTML for your document with innerHTML.
Instance methods
  • getElementById (name:String) : Element
    • To get a instance of an Element you can pass in the id of that node.
  • update (width:int, height:int) : void
    • To update the size of your documnet you can call this method,
  • div (target:DisplayObjectContainer, xml:XML) : DisplayObjectContainer
    • A div tag is sent to this method to be rendered.
  • cdata (target:DisplayObjectContainer, xml:XML) : Text
    • A text node or unknown tag is sent to this method to be rendered.

Constructor

HTML

public function HTML (
width:int, height:int)

Parameters:
width :
The width of the document
height:
The height of the document

Instance properties

innerHTML

public innerHTML:String
(write)

Set the HTML for your document with innerHTML.
To keep this library simple you must structure your HTML string to be valid XML.
Your HTML will be parsed as soon as you have set this property.
Parameters:
html:
String of HTML to be parsed

styleSheet

public styleSheet:String
(write)

A CSS Stylesheet can be set here and used to style your HTML nodes
Parameters:
styles:
String of CSS styles

Instance methods

cdata

public function cdata (
target:DisplayObjectContainer, xml:XML) : Text

A text node or unknown tag is sent to this method to be rendered. A Text node is just
a extened TextField, anything that can be set inside of a ActionScript TextField object
can be defined in your CSS style sheet to modify this object. The width and height
are base of of the parent.
Parameters:
target:
The DisplayObjectContainer that the created Element will be added to.
xml :
The XML node that this Element will be rendered from
Returns:
  • Returns the DisplayObjectContainer that was created

div

public function div (
target:DisplayObjectContainer, xml:XML) : DisplayObjectContainer

A div tag is sent to this method to be rendered. A basic Element is created and
all of the attributes from the node are combined with the styles from the style sheet
to style and then render this element. After the Element is added to the display list
the element is positioned based on its styles. Only the most basic properties can be
used within the style sheet to style these elements.
Parameters:
target:
The DisplayObjectContainer that the created Element will be added to.
xml :
The XML node that this Element will be rendered from
Returns:
  • Returns the DisplayObjectContainer that was created

getElementById

public function getElementById (
name:String) : Element

To get a instance of an Element you can pass in the id of that node.
A Element is a subclass of Sprite, you can add events to them or change any of there properties.
Note: If you call update the instance that you had will be deleted and a new one created.
Parameters:
name:
The ID of a node that you are looking for as a String
Returns:
  • Returns the instance of the Element with the name passed in or Null

update

public function update (
width:int, height:int) : void

To update the size of your documnet you can call this method,
this is useful when resizing your browser window or if you have changed anything
This method will recreate the document from scratch
Note: Make sure to recreate any listeners that you need after this has been called
Parameters:
width :
An intager of the width of your document
height:
An intager of the height of your document