Packageasgard.text
Classpublic class FontLoader
InheritanceFontLoader Inheritance CoreLoader Inheritance flash.display.Loader

This loader load an external swf who contains embed fonts.

Example :

     import asgard.events.FontEvent ;
     import asgard.text.CoreTextField ;
     import asgard.text.FontLoader ;
     
     import flash.events.Event ;
     import flash.net.URLRequest ;
     import flash.system.LoaderContext ;
     import flash.text.TextFormat ;
     
     var field1:CoreTextField = new CoreTextField( null , 150 , 20 ) ;
     field1.border     = true ;
     field1.embedFonts = true ;
     field1.x          = 25 ;
     field1.y          = 25 ;
     
     var field2:CoreTextField = new CoreTextField( null , 150 , 20 ) ;
     field2.x      = 25 ;
     field2.y      = 50 ;
     field2.border = true ;
     
     field2.textColor = 0x000000 ;
     field2.embedFonts = true ;
     
     addChild(field1) ;
     addChild(field2) ;
     
     var addFont:Function = function( e:FontEvent ):void
     {
         trace( e.type + " font:" + e.font ) ;
     }
     
     var complete:Function = function( e:Event )
     {
     
         trace( "fonts : " + Font.enumerateFonts() ) ;
         
         field1.defaultTextFormat = new TextFormat("Arial Black", 12 , 0xFFFFFF ) ;
         field1.text = "hello world" ;
         
         field2.defaultTextFormat = new TextFormat("Myriad Pro", 12 , 0xFFFFFF ) ;
         field2.text = "hello world" ;
     }
     
     var request:URLRequest = new URLRequest( "fonts/fonts.swf" ) ;
     
     var loader:FontLoader = new FontLoader() ;
     
     loader.context = new LoaderContext( false , ApplicationDomain.currentDomain ) ;
     
     loader.contentLoaderInfo.addEventListener( Event.COMPLETE , complete ) ;
     loader.addEventListener( FontEvent.ADD_FONT , addFont ) ;
     
     loader.registerFontClassName( "ArialBlack" ) ;
     loader.registerFontClassName( "MyriadPro" ) ;
     
     // You can use the autoRegister flag, the loader find the Font class in the external library for you
     // loader.autoRegister = true ;
     
     loader.load( request  ) ;
     

the external file "font/fonts.swf" contains in this library the two Font symbols.



Public Properties
 PropertyDefined by
  autoRegister : Boolean
Indicates if the fonts in the external swf library (symbol class) are auto registered when the external file is loading.
FontLoader
 Inheritedcontext : LoaderContext
(read-write) The LoaderContext object of this loader.
CoreLoader
 Inheritedid : *
Returns the id of this object.
CoreLoader
 InheritedisConfigurable : Boolean
Indicates if the display is configurable.
CoreLoader
Protected Properties
 PropertyDefined by
  _fontClassNames : HashSet
The font class name.
FontLoader
Public Methods
 MethodDefined by
  
FontLoader(id:* = null, isConfigurable:Boolean = false, name:String = null)
Creates a new FontLoader instance.
FontLoader
 Inherited
Returns the internal ILogger reference of this ILogable object.
CoreLoader
 Inherited
hashCode():uint
Returns a hashcode value for the object.
CoreLoader
 Inherited
isLocked():Boolean
Returns true if the object is locked.
CoreLoader
 Inherited
load(request:URLRequest, context:LoaderContext = null):void
Loads a SWF, JPEG, progressive JPEG, unanimated GIF, or PNG file into an object that is a child of this Loader object.
CoreLoader
 Inherited
lock():void
Locks the object.
CoreLoader
  
registerFontByName(name:String, domain:ApplicationDomain = null):void
Register the specified Font with the passed-in font name.
FontLoader
  
registerFontClassName(name:String):Boolean
Registers a new FontClassName in the specified FontLoader.
FontLoader
 Inherited
resetLock():void
Reset the lock security of the display.
CoreLoader
 Inherited
setLogger(log:ILogger = null):void
Sets the internal ILogger reference of this ILogable object.
CoreLoader
 Inherited
setup():void
Setup the IConfigurable object.
CoreLoader
  
size():uint
Returns the number of embed fonts to load and create with this loader.
FontLoader
  
toArray():Array
Returns the Array representation of the font names.
FontLoader
 Inherited
toString():String
Returns the String representation of this object.
CoreLoader
 Inherited
unlock():void
Unlocks the display.
CoreLoader
  
unRegisterFontClassName(name:String):Boolean
Unregisters a new FontClassName in the specified FontLoader.
FontLoader
 Inherited
update():void
Update the display.
CoreLoader
Protected Methods
 MethodDefined by
  
complete(e:Event):void
Invoked when the FontLoader process is complete.
FontLoader
Property detail
autoRegisterproperty
public var autoRegister:Boolean

Indicates if the fonts in the external swf library (symbol class) are auto registered when the external file is loading.

_fontClassNamesproperty 
protected var _fontClassNames:HashSet

The font class name.

Constructor detail
FontLoader()constructor
public function FontLoader(id:* = null, isConfigurable:Boolean = false, name:String = null)

Creates a new FontLoader instance.

Parameters
id:* (default = null) — Indicates the id of the object.
 
isConfigurable:Boolean (default = false) — This flag indicates if the IConfigurable object is register in the ConfigCollector.
 
name:String (default = null) — Indicates the instance name of the object.
Method detail
complete()method
protected function complete(e:Event):void

Invoked when the FontLoader process is complete.

Parameters
e:Event
registerFontByName()method 
public function registerFontByName(name:String, domain:ApplicationDomain = null):void

Register the specified Font with the passed-in font name.

Parameters
name:String — The full class name of the font to register.
 
domain:ApplicationDomain (default = null) — The ApplicationDomain use to get the definition of the Font class with the specified name. If this parameter is null the ApplicationDomain.currentDomain is used.
registerFontClassName()method 
public function registerFontClassName(name:String):Boolean

Registers a new FontClassName in the specified FontLoader.

Parameters
name:String

Returns
Boolean
size()method 
public function size():uint

Returns the number of embed fonts to load and create with this loader.

Returns
uint — the number of embed fonts to load and create with this loader.
toArray()method 
public function toArray():Array

Returns the Array representation of the font names.

Returns
Array — the Array representation of the font names.
unRegisterFontClassName()method 
public function unRegisterFontClassName(name:String):Boolean

Unregisters a new FontClassName in the specified FontLoader.

Parameters
name:String

Returns
Boolean