Asif
Asif

Reputation: 21

HTML in Flex mobile project

I have flex mobile project, and i need to show HTML text in some view of project. Any solution other than the following will be appreciated. Because following techniques fails if HTML is not well formatted.

1: TextArea.textFlow = TextFlowUtil.importFromString("html text goes here");

2: TextArea.textFlow = TextConverter.importToFlow("html text goes here", TextConverter.TEXT_FIELD_HTML_FORMAT);

Thanks, Asif.

Upvotes: 0

Views: 3552

Answers (3)

Codebeat
Codebeat

Reputation: 6610

You better can use a StageWebView object. StageWebView is a wrapper for the native WebView object. It uses the build-in browser to show HTML. You can also load strings like the folowing example shows:

import flash.media.StageWebView;

var webView = new StageWebView();  
webView.stage = this.stage;
webView.viewPort = new Rectangle( 0, 0, this.stage.stageWidth, 100 );
webView.loadString( 'Your HTML Here' );

That's it, cheers.

Upvotes: 0

Barno
Barno

Reputation: 3331

<?xml version="1.0" encoding="utf-8"?>
<!-- mobile_text/HTMLTextView.mxml -->
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark" title="HTMLText View"
        creationComplete="initView()">
    <s:layout>
        <s:VerticalLayout/>
</s:layout>
    <fx:Script>
        <![CDATA[
            import spark.components.supportClasses.StyleableTextField;
            private function initView():void {
                StyleableTextField(ta1.textDisplay).htmlText = "TextArea <b>bold</b><i>italic</i>.";
            }
        ]]>
    </fx:Script>
        <s:TextArea id="ta1" width="100%"/>
</s:View>

Upvotes: 1

JeffryHouser
JeffryHouser

Reputation: 39408

It is generally considered bad practice to use the TLF Framework in mobile for performance reasons; and I am pretty sure that the TextConverter classes you are referencing are part of TLF.

That said, you do have a few options. Start by reading this documentation on Using HTML Text in Mobile Applications. Here are a relevant passage:

To use the htmlText property in mobile text controls, access the property on the StyleableTextField subcontrol.

I'm pretty sure that Both TextInput and TextArea use the StyleableTextField under the hood in their mobile skins.

Upvotes: 0

Related Questions