PDA

View Full Version : Flex dynamically embedding font issue with absolute URL


theelephantwords
06-27-2008, 06:58 PM
hey, so in Flex i'm loading in swf's that have embedded fonts. i have a loadstack class that handles fonts, and registers them. it works fine when i call the swf file relatively, but not absolutely.

i get the error =

ArgumentError: Error #1508: The value specified for argument font is invalid.
at flash.text::Font$/registerFont()


googling the issue, no one's had it shut down when the font swf was absolute. so i was wondering if anyone had any fixes. it's loading the swf correctly, but something is weird with the applicationDomain.

in my app:

LS.addToLoader('http://omgplaylist.com/playa/fonts/kroeger05_53.swf', {type:'font', classes:['Kroeger05_53']});


in the loadstack class:

switch (queue[index][1].type) {
case 'font' :
var classes:String = queue[index][1].classes;
var f:Array = classes.split(',');
var FontLibrary:Class;
for (var k:uint = 0; k<f.length; k++) {
FontLibrary = e.target.applicationDomain.getDefinition(f[k]) as Class;
FontLibrary ? Font.registerFont(FontLibrary) : null;
}
break
}


it gets the FontLibrary correctly, but registerFont fails.

http://omgplaylist.com/playa/ is the app, the text on the bottom uses that font, it's loading relatively -

LS.addToLoader('fonts/kroeger05_53.swf', {type:'font', classes:['Kroeger05_53']});


it's not a problem for me yet, i'll be able to do it the way it is but in the future i might need to change it. i've tried checking for a policy file but that didn't do anything because it's actually getting the swf.

thanks for any help.

theelephantwords
10-09-2008, 04:03 AM
if anyone has any insight, that'd be great. currently i'm having the same issue but not in Flex. I'm in Flash, loading fonts with absolute URLs. i have full access to all servers involved, but it still doesn't register the font.

Edit -
I've looked into applicationDomain, no luck.

Another Edit -
I've also tried registering the font right in the swf that i'm loading and appending that application domain to the main document, which doesn't work.

wvxvw
10-09-2008, 12:45 PM
That'd work the same way in both Flex and Flash since they are using the same language (AS3).
What you can try is: put the crossdomain.xml in the root directory of the site where the loaded SWF resides. Also you'll have to test your SWF locally by running it either from the IDE, or by loading it from localhost (not from C:\whatever\...). Also, you can try to allow parent from the loaded SWF, which isn't a perfect idea because it'll let anyone who loads your SWF access it's content.

dr_zeus
10-09-2008, 06:50 PM
It's also important to note that Flash Player assumes that omgplaylist.com and www.omgplaylist.com are different domains. If you're going to be using both interchangably, you need a crossdomain.xml.