flash on 2009-6-22 famibee forked:0favorite:0lines:49license : MIT License modified : 2009-06-22 13:47:36 Embed Tweet package { import flash.display.Sprite; import flash.text.TextField; import flash.text.TextFieldType; import flash.events.Event; public class Main extends Sprite { private const tfExp:TextField = new TextField(); private const tfInp:TextField = new TextField(); private const tfOut:TextField = new TextField(); public function Main():void { tfExp.x = 20; tfExp.y = 0; tfExp.width = stage.stageWidth - (tfExp.x *2); tfExp.height = 20; tfExp.border = true; tfExp.background = true; tfExp.backgroundColor = 0xFFcccc; tfExp.type = TextFieldType.INPUT; addChild(tfExp); tfExp.addEventListener(Event.CHANGE, function ():void { tfOut.htmlText = tfInp.text.replace(new RegExp(tfExp.text, "<font color='red'>$1</font>")); }); tfExp.text = "/[^\"\'\#]+/g"; tfInp.width = tfExp.width; tfInp.height = (stage.stageHeight - tfExp.height)/2; tfInp.x = tfExp.x; tfInp.y = tfExp.height; tfInp.multiline = true; tfInp.wordWrap = true; tfInp.border = true; tfInp.background = true; tfInp.backgroundColor = 0xccFFcc; tfInp.type = TextFieldType.INPUT; tfInp.text = "Hello 'World'!"; addChild(tfInp); tfOut.width = tfExp.width; tfOut.height = tfInp.height; tfOut.x = tfExp.x; tfOut.y = tfInp.y + tfInp.height; tfOut.multiline = true; tfOut.wordWrap = true; tfOut.border = true; tfOut.background = true; tfOut.backgroundColor = 0xeeeeee; tfOut.text = "Hello 'World'!"; addChild(tfOut); } } } Code Fullscreen Preview Fullscreen TextFieldType.INPUT height Event.CHANGE replace type RegExp addChild width multiline addEventListener text Sprite