Oops, please ignore the Singleton line; it's old code in my testing file.

Also, here's slightly revised to correctly remove listener instead of using 
boolean flag:

        private var myControl:TextInput;

        private function init():void {
                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 {
                this.removeEventListener(Event.ENTER_FRAME, onFrame);
                trace("from onFrame");
                trace(myControl.htmlText);
                trace(myControl.text);
                this.removeChild(myControl);
        }




----- Original Message ----
From: Sid Maskit <[EMAIL PROTECTED]>
To: flexcoders@yahoogroups.com
Sent: Saturday, July 19, 2008 9:49:01 AM
Subject: Re: [flexcoders] Re: htmlText to Text


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.getInstan ce().doSomething ();
                var myText:String = '<p>my text</p>';
                myControl = new TextInput();
                this.addEventListen er(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 <core.nation@ gmail.com>
To: [EMAIL PROTECTED] ups.com
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
>


    


      

Reply via email to