[SIZE=2]I have a “Font Library” containing one font:[/SIZE]
package {
import flash.display.Sprite;
public class Bogusflow extends Sprite {
[Embed(systemFont='Bogusflow', fontName='Bogusflow', fontStyle='normal',
fontWeight='normal',mimeType='application/x-font')]
public static var wrFont:Class;
}
}
[SIZE=2]I can load it from application “X” (an SWF file) as follows, with no errors or exceptions:[/SIZE]
[SIZE=2]X:[/SIZE]
private function InitApp():void {
var ldr:Loader= new Loader();
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, regfont);
ldr.load(new URLRequest("Bogusflow.swf"));
}
[SIZE=2]private function regfont(event:Event):void {[/SIZE]
[SIZE=2]var Bogusflow:Class = Class(LoaderInfo(event.target).applicationDomain.[/SIZE]
[SIZE=2] getDefinition("Bogusflow"));[/SIZE]
[SIZE=2]Font.registerFont(Bogusflow.wrFont); [/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]However, if I load application X from another application “Z” via SWFLoader, and I also specify a new LoaderContext, I get an exception in X when it tries to register the font (although the rest of X still loads).[/SIZE]
[SIZE=2]Z:[/SIZE]
private function InitApp():void {
var img:SWFLoader = new SWFLoader();
img.scaleContent = false;
img.autoLoad = false;
img.loaderContext =
new LoaderContext(false,new ApplicationDomain(null));
img.trustContent = true;
Application.application.addChild(img);
img.load("X.swf");
[SIZE=2]The exception currently is, “Cannot access a property or method of a null object reference”, but at other times the error msg has referenced the font parameter of RegisterFont. The exception goes away if I comment out the new LoaderContext as defined (with the new ApplicationDomain), but I need to keep it in as I get other errors I don’t understand when the ApplicationDomain is shared between X and Z.[/SIZE]
[SIZE=2]I guess it will be a miracle if someone actually reads all this and knows what the solution is.[/SIZE]