{"id":42,"date":"2008-10-23T10:04:00","date_gmt":"2008-10-23T15:04:00","guid":{"rendered":"http:\/\/thaylin.info\/blog\/?p=42"},"modified":"2009-02-11T13:54:12","modified_gmt":"2009-02-11T18:54:12","slug":"embedding-htmltext-in-your-textarea-control","status":"publish","type":"post","link":"https:\/\/www.thaylin.com\/blog\/2008\/10\/23\/embedding-htmltext-in-your-textarea-control\/","title":{"rendered":"Embedding htmlText in your TextArea control"},"content":{"rendered":"<p>So I&#8217;m currently working on my first mxml project at work (I&#8217;ve done other stuff but not at work so they were much less involved).<\/p>\n<p>I realized a little in to the project that using the TextArea control can be a bit of a pain the ass at times. Namely, I couldn&#8217;t find a way to embed fonts that were loaded into the flash and set in a stylesheet that I set the TextArea to use.<br \/> The problem here was that the textArea component only looks for a single font attributed to it in the styleName attribute that cna be set. If it doesn&#8217;t see that there&#8217;s a font there it sets embedFonts = false.<\/p>\n<p>So liking to have as much control over things as possible, and realizing that not being able to embed my html goodness was not acceptable, I extended the TextArea class and after some finagling managed to discover the best means for fixing this. It appeared that the UITextField within the TextArea was dispatching a textFieldStyleChange event after it did it&#8217;s validation. This alowed me to add a listener to the textField and set the embedFonts attribute to whatever I chose. Here is my class: <\/p>\n<pre lang=\"actionscript\" line=\"1\" colla=\"+\">\r\n import flash.events.Event;\r\n import mx.controls.TextArea;\r\n import mx.core.mx_internal;\r\n use namespace mx_internal;\r\n\r\n public class TextArea extends mx.controls.TextArea\r\n {\r\n  public var embedFonts:Boolean = false;\r\n  \r\n  public function TextArea()\r\n  {\r\n   super();\r\n   \r\n  }\r\n  private function handleTextFieldStyleChange(event:Event):void\r\n  {\r\n   textField.embedFonts = this.embedFonts;   \r\n  }\r\n  mx_internal override function createTextField(childIndex:int):void\r\n  {\r\n   \r\n   super.createTextField(childIndex);\r\n   textField.addEventListener(\"textFieldStyleChange\", handleTextFieldStyleChange)\r\n  }\r\n }\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>So I&#8217;m currently working on my first mxml project at work (I&#8217;ve done other stuff but not at work so they were much less involved). I realized a little in to the project that using the TextArea control can be a bit of a pain the ass at times. Namely, I couldn&#8217;t find a way [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[9,6],"tags":[32,15,14,31],"_links":{"self":[{"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/posts\/42"}],"collection":[{"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/comments?post=42"}],"version-history":[{"count":2,"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/posts\/42\/revisions"}],"predecessor-version":[{"id":136,"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/posts\/42\/revisions\/136"}],"wp:attachment":[{"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/media?parent=42"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/categories?post=42"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/tags?post=42"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}