Jump to content
GreenSock

CoolStalin

getDefinitionByName does not work

Recommended Posts

Halo, my dear friends!

 

I have a problem with SWFLoader. I can`t retrieve an asset class from loaded swf using getDefinitionByName() on a local machine, but getClass() works prefect.

 

I found same topic (getDefinitionByName does not work), but it`s not working for me.

 

LoaderMax.defaultContext = new LoaderContext(false, new ApplicationDomain(ApplicationDomain.currentDomain))

 

and I have Error #1065

 

ЧЯДНТ?

Link to comment
Share on other sites

2 questions:

 

1) Are you using the latest version of SWFLoader?

 

2) Why not just use getClass() if you know that's working? Seems much easier and that's the whole point of the method :)

 

If you still need help, please post a very simple set of FLAs that we can publish on our end to see the issue.

Link to comment
Share on other sites

Yes, I use the latest version.

 

Of course I can use getClass(), but I prefer single line "getDefenitionByName()" for built-in and loadable libraries. Early I used BulkLoader, but I didn’t have this problem. It’s just interesting why it works for other guys but it doesn’t work for me.

test.zip

Link to comment
Share on other sites

It looks like the problem is that you're loading the classes (swf) into a separate ApplicationDomain, but you're expecting those classes to be visible in the currentDomain.

 

If you want to load them into the current domain, use this context:

var context:LoaderContext = new LoaderContext(true, ApplicationDomain.currentDomain);

 

Or, if you want to load into a separate ApplicationDomain, you'll need to look up the classes there. Make sense?

 

(just for the record, this isn't an issue with LoaderMax (as far as I can tell) - it's just how ApplicationDomains work in Flash. Maybe BulkLoader just used the currentDomain as the default but that has its own set of problems, like if your subloaded swf uses a class that's named the same, it will overwrite the parent's.)

Link to comment
Share on other sites

Yes, I’ve got it from old topic. Thank you for pointing out my inattention. It works prefect with local files. But what if I have to load them from a remote server?

Link to comment
Share on other sites

If you're loading from a different SecurityDomain (and Flash forces local and network stuff to be in separate SecurityDomains - there's no way around that), then it's impossible to subload the swf in a way that merges its classes into the parent's ApplicationDomain. That would be a major security breach. You'd still need to do what I described above, where you reference the particular ApplicationDomain associated with that swf and get the classes there. Again, this is all simplified with SWFLoader's getClass() method, so feel free to crack open the source code and see how it works. I hope that helps.

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