Embedding htmlText in your TextArea control

Posted By Thaylin on October 23, 2008

So I’m currently working on my first mxml project at work (I’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’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.
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’t see that there’s a font there it sets embedFonts = false.

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’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:

?View Code ACTIONSCRIPT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 import flash.events.Event;
 import mx.controls.TextArea;
 import mx.core.mx_internal;
 use namespace mx_internal;
 
 public class TextArea extends mx.controls.TextArea
 {
  public var embedFonts:Boolean = false;
 
  public function TextArea()
  {
   super();
 
  }
  private function handleTextFieldStyleChange(event:Event):void
  {
   textField.embedFonts = this.embedFonts;   
  }
  mx_internal override function createTextField(childIndex:int):void
  {
 
   super.createTextField(childIndex);
   textField.addEventListener("textFieldStyleChange", handleTextFieldStyleChange)
  }
 }

Comments

One Response to “Embedding htmlText in your TextArea control”

  1. JACKIE says:


    CheapTabletsOnline.com. Canadian Health&Care.Best quality drugs.No prescription online pharmacy.Special Internet Prices. High quality pills. Order pills online

    Buy:Mega Hoodia.Actos.Arimidex.Zyban.Synthroid.Human Growth Hormone.Accutane.Nexium.Prednisolone.Petcam (Metacam) Oral Suspension.Prevacid.100% Pure Okinawan Coral Calcium.Retin-A.Zovirax.Lumigan.Valtrex….

Leave a Reply