• Home
  • About Me
  • AIR Central
  • AS3 Libs
  • Books
  • Flex Central
  • Resources
  • The Guru's
  •  

    AIR HTML Control

    The AIR HTML control is something that is unique to AIR and is very easy to integrate into your application. It can be used to simply load in an external html file by location as shown here:

    1. <?xml version="1.0" encoding="utf-8"?>
    2. <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
    3.     layout="absolute">
    4.     <mx:HTML location="http://blog.everythingflex.com"/>
    5. </mx:WindowedApplication>

    OR

    It can be used for custom html using the htmlText property as shown below:

    1. <?xml version="1.0" encoding="utf-8"?>
    2. <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    3.     <mx:Script>
    4.     <![CDATA[
    5.         [Bindable]
    6.         private var htmlString:String = '<table border="1"><tr><td>A table cell</td></tr><tr><td>Another cell</td></tr></table>';
    7.     ]]>
    8.     </mx:Script>
    9.     <mx:HTML htmlText="{htmlString}" width="300" height="300"/>
    10. </mx:WindowedApplication>

    Note: The htmlText property will only return a value in the second example. To get the html contents of the the component using location, you will need to do a little hack at this time as shown here.

    1. var str:String = html.htmlLoader.window.document.documentElement.innerHTML;
    2. str = str.replace(/\r/g, File.lineEnding);
    3. str = '<html>' + str + '</html>';

    Leave a Reply