简体   繁体   中英

as3 external swf classes loaded

I have external swf (ext.swf) that is loaded in my FlashDevelop as3 project.

When I make check ( objectsList[0] is Class1) I am getting false even though the objectsList[0] element is Class1. The Class1 is in the ext.swf

But when I write command like ( objectListInExternalSwf[0] is Class1) in external swf and then use that swf in my project and make check ( objectsList[0] is Class1) I get true.

My question is: do I have to use all the classes in my external swf so the compiler have to put them in the swf so they can be used in other projects where the swf is loaded as external?

By default, when you load an SWF, its content will be placed into a separate ApplicationDomain. So even if you have the same class, Flash will consider it as different.

To share the same class definition, you have to be in the same ApplicationDomain (or inherit from the same) :

var l : Loader = new Loader;
l.load( new URLRequest("foo.swf"),
        new LoaderContext(false, new ApplicationDomain(ApplicationDomain.currentDomain));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM