save text of textarea and reuse it to replace text in textarea

799 Views Asked by At

Is it possible to save text of textarea (flash 10, as3, cs5) in some variable or so and with its textformat (more than one color) and then reuse it to replace text in textarea?

I tried saving htmlText of textarea but the problem is when i replace it in textarea

tags causes problem. There will always be another extra line.

If anyone wants to view p tags problem try following. Just click on text and then move your down arrow key, cursor will go to next line.

import fl.controls.TextArea;

var txtHTML:TextArea = new TextArea();
txtHTML.move(0,0);

var default_format:TextFormat = new TextFormat();
    default_format.font = "Arial";
    default_format.bold = false;
    default_format.align = "center";
    default_format.color = 0xFFFF00;
    default_format.size = 14;

var field:TextField = txtHTML.textField;
    field.defaultTextFormat = default_format;
    field.setTextFormat(default_format);
    field.alwaysShowSelection = true;
    field.background = true;
    field.type = 'input';
    field.multiline = true;
    field.backgroundColor = 0x777777;
    field.embedFonts = true;   
    txtHTML.htmlText = '<P ALIGN="CENTER"><FONT FACE="_sans" SIZE="14" COLOR="#FFFF00" LETTERSPACING="0" KERNING="0">ASDF</FONT></P>';
    field.x = 0;
    field.y = 0;   
    field.width = 400;
    field.height = 200;
    field.text = "";

addChild(txtHTML);

Is there a way to do this?

1

There are 1 best solutions below

0
user427969 On BEST ANSWER

Just copy the text and remove the last character i.e. '>'. So there won't be <p></p> tags problem of extra line.

Regards