| Package | asgard.text |
| Class | public class FontLoader |
| Inheritance | FontLoader CoreLoader flash.display.Loader |
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.
| Property | Defined by | ||
|---|---|---|---|
| autoRegister : Boolean
Indicates if the fonts in the external swf library (symbol class) are auto registered when the external file is loading.
| FontLoader | ||
![]() | context : LoaderContext
(read-write) The LoaderContext object of this loader.
| CoreLoader | |
![]() | id : *
Returns the id of this object.
| CoreLoader | |
![]() | isConfigurable : Boolean
Indicates if the display is configurable.
| CoreLoader | |
| Property | Defined by | ||
|---|---|---|---|
| _fontClassNames : HashSet
The font class name.
| FontLoader | ||
| Method | Defined by | ||
|---|---|---|---|
|
FontLoader(id:* = null, isConfigurable:Boolean = false, name:String = null)
Creates a new FontLoader instance.
| FontLoader | ||
![]() |
Returns the internal
ILogger reference of this ILogable object. | CoreLoader | |
![]() |
hashCode():uint
Returns a hashcode value for the object.
| CoreLoader | |
![]() |
isLocked():Boolean
Returns
true if the object is locked. | CoreLoader | |
![]() |
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 | |
![]() |
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 | ||
![]() |
resetLock():void
Reset the lock security of the display.
| CoreLoader | |
![]() |
Sets the internal
ILogger reference of this ILogable object. | CoreLoader | |
![]() |
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 | ||
![]() |
toString():String
Returns the
String representation of this object. | CoreLoader | |
![]() |
unlock():void
Unlocks the display.
| CoreLoader | |
|
unRegisterFontClassName(name:String):Boolean
Unregisters a new FontClassName in the specified FontLoader.
| FontLoader | ||
![]() |
update():void
Update the display.
| CoreLoader | |
| Method | Defined by | ||
|---|---|---|---|
|
complete(e:Event):void
Invoked when the FontLoader process is complete.
| FontLoader | ||
| autoRegister | property |
public var autoRegister:BooleanIndicates if the fonts in the external swf library (symbol class) are auto registered when the external file is loading.
| _fontClassNames | property |
protected var _fontClassNames:HashSetThe font class name.
| FontLoader | () | constructor |
public function FontLoader(id:* = null, isConfigurable:Boolean = false, name:String = null)Creates a new FontLoader instance.
Parametersid:* (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.
|
| complete | () | method |
protected function complete(e:Event):voidInvoked when the FontLoader process is complete.
Parameterse:Event |
| registerFontByName | () | method |
public function registerFontByName(name:String, domain:ApplicationDomain = null):voidRegister the specified Font with the passed-in font name.
Parametersname: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):BooleanRegisters a new FontClassName in the specified FontLoader.
Parametersname:String |
Boolean |
| size | () | method |
public function size():uintReturns the number of embed fonts to load and create with this loader.
Returnsuint — the number of embed fonts to load and create with this loader.
|
| toArray | () | method |
public function toArray():ArrayReturns the Array representation of the font names.
ReturnsArray — the Array representation of the font names.
|
| unRegisterFontClassName | () | method |
public function unRegisterFontClassName(name:String):BooleanUnregisters a new FontClassName in the specified FontLoader.
Parametersname:String |
Boolean |