Jump to content
Search Community

SWFLoader problem with absolute paths...

sentoplene test
Moderator Tag

Recommended Posts

Hi,

 

I'm using LoaderMax in conjunction with SWFLoaders...

And it seems that everything works fine when given relative paths of the swf's.

 

But when I receive absolute paths, I get weird problems...

 

var context :LoaderContext = new LoaderContext();
context.checkPolicyFile = true;
//context.securityDomain = SecurityDomain.currentDomain;
context.applicationDomain = ApplicationDomain.currentDomain;


// create a LoaderMax named "mainQueue" and set up onProgress, onComplete and onError listeners
var queue :LoaderMax = new LoaderMax({	name:"gamePhotosQueue", auditSize: false, defaultContext: context,
									onProgress: progressHandler, 
									onComplete:completeHandler, 
									onError: errorHandler	 });

for (var i : int = 0; i < l; i++) 
{
queue.append(new SWFLoader(url, {name: id, noCache: false, autoPlay: false}));
}

 

Then when further in my code I want to access the swf it gives me:

countryloader = LoaderMax.getLoader('country' + CountryVO(_vo.countries[i]).countrycode);
trace('countryloader: ' + (countryloader));                                        // traces Object SWFLoader
trace('countryloader.rawContent: ' + (countryloader.rawContent));   // traces Object CountryVideo
country = countryloader.rawContent as CountryVideo;
trace('country: ' + (country)); // traces NULL ???????

 

So that's weird... and I tried al kinds of contexts

checkPolicyFile = false;

applicationDomain = new ApplicationDomain()

 

and the above with different settings...

 

Any idea?

So it loads it but eventually when I cast it to a local var, it won't let me...

And this is only with absolute paths, with relative all works fine...

Link to comment
Share on other sites

When you load things into another SecurityDomain, those classes are segregated and you cannot access them from your main/parent swf. It's a security thing. It has nothing to do with LoaderMax. If you test your swf locally and have it load things from the web (as I assume your absolute URLs are doing), Flash forces those into a separate SecurityDomain. As far as I can tell, it's absolutely impossible to load them into the same SecurityDomain as the local swf.

 

So think of those subloaded classes as being walled off and isolated. You cannot use them to cast things either. So when you trace(countryloader.rawContent), all that does is call the rawContent's toString() method and print it to the screen, so you see "object CountryVideo" but that doesn't mean that it actually has access to the CountryVideo class itself. Then when you try to cast it, Flash is kinda like "not so fast, bub - that content is out of your reach. It's in a different SecurityDomain, so you ain't gettin' access to it". When a casting operation fails, it simply returns null.

 

Hope that clears things up.

 

Again, this has nothing to do with LoaderMax - it's just a Flash thing. You'd run into the same issue if you tried using a plain Loader from Adobe.

Link to comment
Share on other sites

  • 2 years later...

I'm running into this issue as well. Is there any way around this? I'd really like to be able to cast my loaded children SWF as they are, so I have access to their properties and methods.

 

FWIW, It seems to work when I test my parent SWF on my development server (pulling the children SWF from another domain), but not when testing locally. 

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...