186 posts
  • Has been part of the Envato Community for over 6 years
  • Has referred 10+ members
  • Has sold $5,000+ on Envato Market
  • Has collected 1+ items on Envato Market
+4 more

Really good idea bitfade, thanks, bookmarked.

4140 posts
  • Has been part of the Envato Community for over 6 years
  • Has referred 1+ members
  • Has sold $5,000+ on Envato Market
  • Located in Brazil
+4 more

load External Font simple way Dispatch class (for CS3)
    import flash.display.Loader;
    import flash.events.Event;
    import flash.events.EventDispatcher;
    import flash.events.IOErrorEvent;
    import flash.net.URLRequest;
    import flash.system.ApplicationDomain;
    import flash.text.Font;

         //Font Loader
    public class ExternalFont extends EventDispatcher
        public static const COMPLETE:String = "fontLoad";
        public static const ERROR:String    = "error";

        private var _ld:Loader;
        private var _Dom:ApplicationDomain;
        private var _Font:Array;
        private var _fontClass:Class;

        // ExternalFont Dispatcher url & font name
        public function ExternalFont(_url:String,fonts:Array):void
            _ld = new Loader();
            _Font = fonts;

    //_ld.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, _onIOError);
            _ld.contentLoaderInfo.addEventListener(Event.COMPLETE, _complete);

            var req = new URLRequest(_url);

        // if fonts  loaded you can pull fonts if you whant

        public function get(_setId:String):Font {            
            return _Dom.getDefinition(_setId) as Font;

        //set extract fonts on Complete
        private function _complete(e:Event):void {
            _Dom = _ld.contentLoaderInfo.applicationDomain;
            var i:Number;
            for (i = 0; i < _Font.length; i++) {
                _fontClass = _Dom.getDefinition(_Font[i]) as Class;

            dispatchEvent(new Event(ExternalFont.COMPLETE));

        //if IOErrorEvent set Arial
        //private function _onIOError(e:IOErrorEvent):void {
        //    dispatchEvent(new Event(ExternalFont.ERROR));

main class
var _font:ExternalFont = new ExternalFont("swfFont.swf", ["MyFont"]);//registerFont in swfFont.swf (MyFont)
var txt:TextField=new TextField();
var tf:TextFormat=new TextFormat();
_font.addEventListener(ExternalFont.COMPLETE, _complete );
//_font.addEventListener(ExternalFont.ERROR, _error);

//function _error(e:Event) {
//    tf.font="Arial"; // if error set Arial .
//    txt.embedFonts = false;
//    setFormat();

function _complete (e:Event) {
    var embeddedFonts:Array = Font.enumerateFonts(false);
    txt.embedFonts = true;

function setFormat(){
    tf.size = 16;
    txt.defaultTextFormat = tf;
    //txt.x = 0;
    //txt.y = 0;
    //txt.autoSize = TextFieldAutoSize.LEFT;
    txt.htmlText = "Hit me Baby";

1 post
  • Has been part of the Envato Community for over 3 years
  • Located in Ukraine
tsafi said

load External Font ...

Very useful, tnx!=)

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes