Jump to content
Search Community

Loading Font from external swf

chris12345 test
Moderator Tag

Recommended Posts

So I have a swf file with an embedded font I made in Flash Pro. 

What I'm trying to do is dynamically load this swf into my project using LoaderMax and SWFLoader, then register that font so it can be used later. The swf is downloaded and stored locally beforehand. It seems to be loading the swf fine, the problem is when I try to register the font, it throws an error saying the class from the swf is invalid.


Code to load the SWF:

FontLoader = new LoaderMax( { onComplete: fontsLoaded, skipFailed: true } );

for(var i:int=0; i < mainXML.Fonts.Font.length(); i++)
	name = mainXML.Fonts.Font[i].FontFamily.text();
	fileName = File.applicationStorageDirectory.resolvePath("UpsellAssets/" + name + ".swf").nativePath;
	FontLoader.append( new SWFLoader( fileName, { name: name } ) );

onComplete function:

private function fontsLoaded(e:LoaderEvent):void
	var loader:SWFLoader = FontLoader.getLoader("Myriad");
	_fontClass = loader.getClass("Myriad")
	Font.registerFont(_fontClass);//throws error here...The value specified for argument font is invalid.

_fontClass seems to load properly, but I cant seem to access the font. Any insight on what might be wrong would be greatly appreciated. Thanks ^.^

Link to comment
Share on other sites

Thanks for the response. I've pretty much tried everything in that thread with no luck. I can load up the class just fine, but it fails when I try to register the font. So the only thing I can really think of is it being an issue with how I put together the swf. But all I'm doing is dragging a dynamic textfield onto the stage, setting the font, then hitting embed in the propertiies panel. Then I setup the name, character ranges, and export for actionscript, which from what I've read is correct so I'm not sure what could be the issue.

Link to comment
Share on other sites

Hey there, I'm stuck on the same issue. I've poured over that thread multiple times and the only issue I can see is if my fonts aren't embedding properly.


If I go into the library and edit the class of the embedded font this is all the code that comes up:

package  {
	import flash.text.Font;
	public class Myriad extends Font {
		public function Myriad() {
			// constructor code

Which doesn't feel right.


The only thing i can think of is in that post it lists using Dynamic "classic" Text rather then TTL, but I honestly don't know what each one is.


I am using Flash CC

Link to comment
Share on other sites

Yeah, sounds like one of these classic "annoying Flash things". Frankly I do not have much experience with what you are trying to do, but I can guess I've probably spent around 100 hours of my life dealing with Flash and embedded font related problems.


My gut feeling is that LoaderMax is not getting in the way of this working. I think I would step back and try to get this working with a very basic AS3 Loader (no third party tools) and see if it works. I think if you start down that path you will have better luck, I have to imagine there are some sample files floating around other more generic Flash support forums that handle this. I would grab one of those and modify it to work with your fonts and once that works, throw LoaderMax back in.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...