Packageardisia.components.autoFitText
Classpublic class AutoFitFTETextField
InheritanceAutoFitFTETextField Inheritance mx.core.FTETextField

Spark FTETextField that will automatically set its fontSize to fill its available space without triggering truncation. Uses an efficient sizing algorithm. Provide explicit dimensions to fit an exact space.

FTETextfield is very fast. Much, much faster than a spark Label, but it does not implement IVisualElement so it can only be added to DisplayObjectContainers (E.G. UIComponent). Also, FTETextfield does not participate in layout, or css, so any changes in size/position/styling need to accomplished manually in the parent layout. Also, the fitText() method must be called manually and the dimensions must be set explicitly.

Therefore, the primary purpose of this class is as a label in an item renderer extending UIComponent when performance is a priority.

View the technical documentation on the Ardisia Labs website for more information.

DESIGN NOTES

Since the FTETextField does not support TLF, intra-word wrapping cannot be stopped via the "breakOpportunity" style. RichText does support the "breakOpportunity" style.

Scaling will not work because the entire component will scale, not just the text.

Initial guessing difficult because of line wrapping.



Public Properties
 PropertyDefined By
  autoSize : String
[override]
AutoFitFTETextField
  ignoreWordLength : Number
Any words with less than or equal to the number of characters defined by this property will not be included in the word count.
AutoFitFTETextField
  maxFontSize : Number
The maximum allowed fontSize.
AutoFitFTETextField
  minFontSize : Number
The minimum allowed fontSize.
AutoFitFTETextField
  precisionThreshold : Number
The font size precision used by the class to determine when the fit is 'good enough', in pixels.
AutoFitFTETextField
Public Methods
 MethodDefined By
  
AutoFitFTETextField
  
fitText():void
Will set the fontSize to fill the available space without clipping.
AutoFitFTETextField
Protected Methods
 MethodDefined By
  
Determines the number of words in the "text" property string.
AutoFitFTETextField
Property Detail
autoSizeproperty
autoSize:String[override]


Implementation
    public function get autoSize():String
    public function set autoSize(value:String):void
ignoreWordLengthproperty 
ignoreWordLength:Number

Any words with less than or equal to the number of characters defined by this property will not be included in the word count. This is relevant because the number of line breaks cannot exceed the word count.

The default value is 3.


Implementation
    public function get ignoreWordLength():Number
    public function set ignoreWordLength(value:Number):void
maxFontSizeproperty 
maxFontSize:Number

The maximum allowed fontSize.

The default value is 6.


Implementation
    public function get maxFontSize():Number
    public function set maxFontSize(value:Number):void
minFontSizeproperty 
minFontSize:Number

The minimum allowed fontSize.

The default value is 6.


Implementation
    public function get minFontSize():Number
    public function set minFontSize(value:Number):void
precisionThresholdproperty 
precisionThreshold:Number

The font size precision used by the class to determine when the fit is 'good enough', in pixels.

Higher values will increase performance but not fit as optimally.

The default value is 2.


Implementation
    public function get precisionThreshold():Number
    public function set precisionThreshold(value:Number):void
Constructor Detail
AutoFitFTETextField()Constructor
public function AutoFitFTETextField()



Method Detail
calculateWordCount()method
protected function calculateWordCount():void

Determines the number of words in the "text" property string. Ignores any words with a character length less than the "ignoreWordLength" property.

fitText()method 
public function fitText():void

Will set the fontSize to fill the available space without clipping.