I don't know if this will be of interest to anyone, but I learned something
trying to respond to this post. I thought that it would be cool to do this
entire thing within ActionScript. I managed to get it working, but it took a
little bit more than I thought it would.
One can use the text input control to convert from HTML to plain text, but the
control must be on the stage for at least one frame. Thus I end up with the
following code (within a script tag):
private var myControl:TextInput;
private var done:Boolean;
private function init():void {
Singleton.getInstance().doSomething();
var myText:String = '<p>my text</p>';
myControl = new TextInput();
this.addEventListener(Event.ENTER_FRAME, onFrame);
myControl.htmlText = myText;
this.addChild(myControl);
trace("from init");
trace(myControl.htmlText);
trace(myControl.text);
}
private function onFrame(event:Event):void {
if (done) {return;}
done = true;
trace("from onFrame");
trace(myControl.htmlText);
trace(myControl.text);
this.removeChild(myControl);
}
To show the change that results from having the control on the stage for a
frame, here's the trace result:
from init
null
from onFrame
<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Verdana" SIZE="10"
COLOR="#0B333C" LETTERSPACING="0" KERNING="0">my text</FONT></P></TEXTFORMAT>
my text
If somebody has a way to have the text input control do the conversion without
having to put the control onto the stage, I would be interested to hear about
that.
Hope somebody finds that useful,
Sid
----- Original Message ----
From: hugocorept <[EMAIL PROTECTED]>
To: [email protected]
Sent: Saturday, July 19, 2008 5:55:24 AM
Subject: [flexcoders] Re: htmlText to Text
Nevermind, i resolved it.
Create a RichTextEditor pass the "htmlText" to it, then accessing to is "Text"
proproety it's
tag free :D
Example:
<mx:RichTextEditor x="20" y="10" title="Title" id="richText" >
<mx:htmlText>
<![CDATA[
<TEXTFORMAT LEADING="2"> <P ALIGN="LEFT" ><FONT
FACE="Verdana" SIZE="10" COLOR="#0B333C" LETTERSPACING= "0" KERNING="0"> Ola
tudo bem?</FONT>< /P></TEXTFORMAT>
]]>
</mx:htmlText>
</mx:RichTextEditor >
<mx:TextArea x="491" y="10" width="260" height="300"
backgroundColor= "#0E0E0E" color="#FFFFFF" text="{richText. text}"/>
The text in the TextArea are not formated was i wanted :)
Thanks, anyway
--- In [EMAIL PROTECTED] ups.com, "hugocorept" <core.nation@ ...> wrote:
>
> Hi guys,
>
> Does somebody have an idea to convert htmlText to text, it means remove the
> Angle
> Brackets.
>
> Example:
>
> <FONT ...>Lorem Ipsum</FONT>
>
> to
>
> Lorem Ipsum
>
>
>
> I don't know, RegExp, some String Method ? :S
>
> Thanks,
> Core
>