Calendar

February 2008
M T W T F S S
« Jan   Mar »
 123
45678910
11121314151617
18192021222324
2526272829  

Tag Cloud

Categories

Archives

Highest Rated

Most Viewed

Recent Posts

Recent Comments


« Create Images with AIR and JPEGEncoder | Main | AIR ActionScript / JavaScript Bridge »

AIR HTML Control

By Rich Tretola | February 25, 2008Print This Post Print This Post
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...
104 views

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>';

Share/Save/Bookmark

Topics: Adobe AIR |

Comments