Packageardisia.components.autoFitText
Classpublic class AutoFitRichText
InheritanceAutoFitRichText Inheritance spark.components.RichText

Spark RichText that will automatically set its size to fit the available space without truncation. Provide explicit dimensions to fit an exact space.

Slower than the AutoFitLabel and the AutoFitFTETextField but supports TLF and does a better job of not word wrapping intra-word because it supports the "breakOpportunity" style.

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

DESIGN NOTES

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

Default MXML Propertycontent



Public Properties
 PropertyDefined By
  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.
AutoFitRichText
  maxFontSize : Number
The maximum allowed fontSize.
AutoFitRichText
  minFontSize : Number
The minimum allowed fontSize.
AutoFitRichText
  precisionThreshold : Number
The font size precision used by the class to determine when the fit is 'good enough', in pixels.
AutoFitRichText
Public Methods
 MethodDefined By
  
AutoFitRichText
  
dispose():void
Call to remove the component from the display list and remove any event listeners.
AutoFitRichText
  
fitText():void
Will set the label fontSize to fill the available space without truncation.
AutoFitRichText
Protected Methods
 MethodDefined By
  
Determines the number of words in the "text" property string.
AutoFitRichText
  
eventHandler(event:Event):void
Handles events on the control.
AutoFitRichText
  
getNumLines():Number
Returns the number of text lines.
AutoFitRichText
Property Detail
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 60.


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
AutoFitRichText()Constructor
public function AutoFitRichText()



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.

dispose()method 
public function dispose():void

Call to remove the component from the display list and remove any event listeners.

eventHandler()method 
protected function eventHandler(event:Event):void

Handles events on the control.

Parameters

event:Event — the Event that triggered the handler

fitText()method 
public function fitText():void

Will set the label fontSize to fill the available space without truncation.

getNumLines()method 
protected function getNumLines():Number

Returns the number of text lines.

Returns
Number — int of the number of lines