| Package | vegas.text |
| Class | public class FontLoader |
| Inheritance | FontLoader CoreLoader flash.display.Loader |
Example :
import vegas.events.FontEvent ;
import vegas.text.CoreTextField ;
import vegas.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
The LoaderContext object of this loader. | CoreLoader | |
![]() | logger : Logger
Determinates the internal ILogger reference of this Logable object. | CoreLoader | |
| Property | Defined By | ||
|---|---|---|---|
| _fontClassNames : HashSet
The font class name. | FontLoader | ||
| Method | Defined By | ||
|---|---|---|---|
Creates a new FontLoader instance. | FontLoader | ||
![]() | isLocked():Boolean
Returns true if the object is locked. | CoreLoader | |
![]() | load(request:URLRequest, context:LoaderContext = null):void [override]
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 | |
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 | ||
![]() | unlock():void
Unlocks the display. | CoreLoader | |
unRegisterFontClassName(name:String):Boolean
Unregisters a new FontClassName in the specified FontLoader. | FontLoader | ||
| Method | Defined By | ||
|---|---|---|---|
complete(e:Event):void
Invoked when the FontLoader process is complete. | FontLoader | ||
| Event | Summary | Defined By | ||
|---|---|---|---|---|
| Dispatched when a new font is registered in the application. | FontLoader | |||
| _fontClassNames | property |
protected var _fontClassNames:HashSetThe font class name.
| 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.
| FontLoader | () | Constructor |
public function FontLoader()Creates a new FontLoader instance.
| complete | () | method |
protected function complete(e:Event):voidInvoked when the FontLoader process is complete.
Parameters
e:Event |
| registerFontByName | () | method |
public function registerFontByName(name:String, domain:ApplicationDomain = null):voidRegister 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):BooleanRegisters a new FontClassName in the specified FontLoader.
Parameters
name: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.
Parameters
name:String |
Boolean |
| addFont | Event |
vegas.events.FontEventvegas.events.FontEvent.ADD_FONTDispatched when a new font is registered in the application.