UK Mobile Phone Review |

Calendar

March 2007
S M T W T F S
« Feb   Apr »
 123
45678910
11121314151617
18192021222324
25262728293031

Tag Cloud

Categories

Archives

Recent Posts

Recent Comments


« Windowing with Apollo - full source code | Main | FileSystem Components »

HTML Control

By Rich Tretola | March 19, 2007Print This Post Print This Post
6,417 views

The mx:HTML control is something that is unique to Apollo 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
2
3
4
5
6
<?xml version=1.0″ encoding=”utf-8″?>
<mx:ApolloApplication
xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute”>
<mx:HTML id=”html”
location=”http://blog.everythingflex.com”/>
</mx:ApolloApplication>

OR

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

1
2
3
4
5
6
7
8
9
10
11
<?xml version=”1.0″ encoding=”utf-8″?>
<mx:ApolloApplication
xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute”>
<mx:Script>
<![CDATA[
[Bindable]
private var htmlString:String = “<table><tr><td>A table cell</td><td>Another cell</td></tr></table>”;
]]>
</mx:Script>
<mx:HTML id=”htmlhtmlText=”{htmlString}/>
</mx:ApolloApplication>

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
2
3
var str:String = html.htmlControl.window.document.documentElement.innerHTML;
str = str.replace(/\r/g, File.lineEnding);
str = '<html>' + str + '</html>';

The Apollo team is still considering whether to allow the full page source to be returned natively.

Share this Post


Topics: Adobe AIR, Tutorials |

13 Responses to “HTML Control”

  1. Brandon Aikin Says:
    March 26th, 2007 at 8:29 am

    I see a compile time error: ‘location’ is read only. This works, for the most part:

    htmlControl.load(new URLRequest(”http://www.somedomain.com”));

    How would one go about viewing .swf or .mov content within a loaded html page?

  2. The Outlander Says:
    March 27th, 2007 at 10:34 pm

    Hi,

    Can this control be used in FLEX? We are trying to render html and the textarea control that they have does very basic tags ….. it would be great to import this control in flex …

    - Nik

  3. everythingflex Says:
    March 28th, 2007 at 3:28 am

    No, it can not be used in Flex and I would suspect that it never will as it would require adding many megabytes to the size of the Flash Player download (including the full Safari Web kit). This would slow the download rate of the Flash Player which would definitely not be in Adobe’s best interest.

  4. - Chris :: Flex Factory Says:
    April 3rd, 2007 at 6:30 pm

    Hi Nik,

    use an IFrame like this….

  5. jude Says:
    April 8th, 2007 at 5:30 pm

    Hi guys,

    I’ve been working on a Flex HTML component for the last couple months that works with the browser and Flex to provide the same functionality. It was released last month and the swc is free. It is very similar to the HTML Control for Apollo and has some of the same features (slight variations in a few of the property names). The funny thing is these were both developed independent of each other. The HTML Component was built off the work I did in the HTML Overlay component for Flash MX 2004 and is around 3rd generation client side code. Of course it can always be improved and feedback is welcome.

    http://www.judahfrangipane.com/blog/?p=104

  6. everythingflex Says:
    April 8th, 2007 at 6:58 pm

    Jude,

    Very cool, thanks for sharing this.

  7. tiberiu Says:
    June 14th, 2007 at 3:31 am

    It seems that the html image mapping not working in mx:HTML control… this is true, or I have done something wrong?

  8. everythingflex Says:
    June 14th, 2007 at 9:05 am

    It seems to be working fine when I try it. Make sure you are using the newest AIR beta.

    Try this code within your AIR application:

    1
    <mx:HTML location="http://www.htmlcodetutorial.com/images/images_famsupp_220.html"/>
  9. CarterCoder Says:
    October 19th, 2007 at 9:48 am

    Hey, Jude –

    You mention that the HTML component for Flex is free, but when I follow your link I get to a page that says it’s $149. Did I do something wrong? If so, what is the direct link to the free download?

  10. everythingflex Says:
    October 19th, 2007 at 11:03 am

    My post was on the HTML control for Apollo which is now AIR. I didn’t post any links, You must be referring to a link that someone posted in a comment.

  11. Alistair Says:
    October 25th, 2007 at 3:38 pm

    I have created a modified version of the IFrame component which was developed originally I believe by Christophe Conraets and then subsequently improved by Brian Deitte.

    I am using it to host a Google Map in a Flex application. It’s free with source code and demos. You can get it here:

    http://ccgi.arutherford.plus.com/blog/wordpress/?page_id=132

    Cheers.

    Al.

  12. judah Says:
    December 18th, 2007 at 3:23 pm

    Hi Carter,

    You can still get version 2 free here, http://drumbeatinsight.com/forums/viewtopic.php?t=610. If you want to use the control in pop ups (there was a bug in version 2) or if you want to use it in FB3 then there is the commercial version that you found here, http://www.drumbeatinsight.com/htmlcomponent.

    Best,
    Judah

  13. Mike Says:
    March 16th, 2009 at 8:53 am

    Hi,

    Is there still a free version of an HTML component that I can download ?

    Thanks

Comments