PDA

View Full Version : Help Changing Application Domain with SWFLoader


BigTimeOperator
02-16-2009, 01:41 AM
I have a base.swf that loads in an external.swf and tries to add the external swfs document class to it's application domain and then create a new instance of that class. I'm getting the error described below, but I really can't figure out why. Here is a simplified version of what I am doing, can anyone shed some light on this for me?

1 - external swf published from an fla using SomeClass as it's document class:

someswf.swf published with document class set to com.whatever.SomeClass;

2- base swf compiled with flex 3 sdk loads the external swf, and sets the applicaiton domain

var swfloader:SWFLoader = new SWFLoader();
swf.loaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
swfloader.load(someswf.swf);

3- After the swfloader loads, try to create a new instance SomeClass

var className:String = getQualifiedClassName(swfloader.content); //traces com.whatever::SomeClass;
var someClassInstance:Class = getDefinitionByName(className) as Class; //gives error saying "Variable SomeClass not defined"

Roustalski
11-11-2009, 04:51 PM
in stead of:

swf.loaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);

use:

swf.loaderContext = new LoaderContext(false, new ApplicationDomain() );

Roustalski
11-11-2009, 05:26 PM
Or rather:

swf.loaderContext = new LoaderContext(false, new ApplicationDomain( ApplicationDomain.currentDomain ) );