text and htmlText using appendText

by WLAD
the problem is: it's impossible to use the function appendText and append it as html text.

♥0 | Line 76 | Modified 2014-01-09 22:27:14 | MIT License
play

ActionScript3 source code

/**
 * Copyright WLAD ( http://wonderfl.net/user/WLAD )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/v4Oo
 */

package {
	import com.bit101.components.Label;
	import com.bit101.components.PushButton;
	import com.bit101.components.Style;
    import flash.display.Sprite;
	import flash.text.TextField;
	import flash.text.TextFormat;
    public class FlashTest extends Sprite {
		
		private var inputText:TextField;
		private var textField:TextField;
		
		private var leftText:TextField;
		private var rightText:TextField;
		
        public function FlashTest() {
            // write as3 code here..
            
			var ypos:Number = 20;
Style.LABEL_TEXT = 0x506730;
			inputText = new TextField();
			formatText(inputText, 0x3F4372);
			addChild(inputText);
			inputText.y = ypos;
			inputText.type = "input";
			inputText.text = 'EDIT ME!!! <br/><br/><P ALIGN="LEFT"><FONT FACE="Verdana" SIZE="16" COLOR="#000000" LETTERSPACING="0" KERNING="0"><B>Edit MeZZaaaa<br/>Trixy</B></FONT></P>';
			new Label(this, inputText.x, ypos - 20, "inputTextText - !!!!!!EDIT THIS TEXT FIELD!!!!!!");
			
			ypos = 125;
			
			new PushButton(this, 10, ypos, "textField.appendText(inputTextText.text);", function(e:*= null):void {
				textField.appendText(inputText.text);
				inputText.text = "";
			}).width = stage.stageWidth/2 - 20;
			new PushButton(this, stage.stageWidth/2, ypos, "textField.text = inputTextText.text;", function(e:*= null):void {
				textField.text = inputText.text;
				inputText.text = "";
			}).width = stage.stageWidth / 2 - 10;
			
			ypos += 30;
			
			new PushButton(this, 10, ypos, "textField.htmlText = inputTextText.text;", function(e:*= null):void {
				textField.htmlText = inputText.text;
				inputText.text = "";
			}).width = stage.stageWidth/2 - 20;
			
			ypos += 50;
			
			textField = new TextField();
			formatText(textField);
			addChild(textField);
			textField.y = ypos;
			new Label(this, textField.x, textField.y - 20,"textField");
			
			ypos = 350;
			leftText = new TextField();
			formatText(leftText, 0xE70E0E, 12);
			addChild(leftText);
			leftText.y = ypos;
			leftText.width = stage.stageWidth / 2 - 20;
			new Label(this, leftText .x , leftText .y - 20, "leftText.text = textField.text");
			
			rightText = new TextField();
			formatText(rightText, 0x329F2D, 12);
			addChild(rightText);
			rightText.y = ypos;
			rightText.width = stage.stageWidth / 2 - 10;
			rightText.x = stage.stageWidth / 2;
			new Label(this, rightText.x , rightText.y - 20, "rightText.text = textField.htmlText");
			
			addEventListener("enterFrame", function(e:*= null):void {
				leftText.text = textField.text;
				rightText.text = textField.htmlText;
			});
			
			textField.htmlText = inputText.text;
        }
		
		private function formatText(t:TextField, color:uint = 0x0, size:int = 16):void
		{
			t.defaultTextFormat = new TextFormat("Verdana", size, color, true);
			t.background = true;
			t.backgroundColor = 0xDDDDDD;
			t.border = true;
			t.wordWrap = true;
			t.multiline = true;
			t.x = 10;
			t.borderColor = 0x0;
			t.width = stage.stageWidth - 20;
		}
    }
}