问题描述
所以我有一种情况,我想将一个类的对象(例如MyBigAwesomeClass")从孩子传递给父母.我将类定义导入到父级和子级中.
So i have a situation where i want to pass a object of a class say 'MyBigAwesomeClass' from a child to a parent. I import the class definition into both the parent and child.
现在,如果我从相对于父级位置的位置加载子 swf,一切都很好,但是当我使用完整的绝对路径加载它时,它会处理父级中BigAwesomeClass"的定义并且在子类中不同,并且不允许将BigAwesomeClass"类型的对象分配给父类中相同的对象.
Now, if i load the child swf from a location that is relative to the location of the parent , all is fine, however the moment i load it using a full absolute path, it treats the definitions for 'BigAwesomeClass' in parent and in child as different and does not allow an object of the type 'BigAwesomeClass' to be assigned to an object of the same in the parent class.
我完全被难住了,我对 ApplicationDomains 感到头疼,包括使用此代码
I am totally stumped, and have banged my head over ApplicationDomains, including using this code
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,swfLoaded);
var context:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
loader.load(new URLRequest(_file.url),context);
完全没有用.关于我能做些什么来解决这个问题的任何想法?
To absolutely no avail.Any ideas as to what can i do it fix this ?
提前致谢
推荐答案
事实证明这是一个沙盒问题.不属于安装程序的文件放置在不同的安全沙箱中,并且由于它们驻留在不同的沙箱中,因此子项在导入到父项时不会继承 ApplicationDomain
中其父项的定义,并且存在两个不相容的独立定义.可悲的是,似乎没有直接的方法来解决这个问题.Adobe 确实允许通过 SandBoxBridge 在沙箱之间进行通信,但这迫使您使用 Object 类型,这违背了整个事情的目的.据我所知,即使它们完全相同,两个不同沙箱中的类也无法兼容.我猜它回到了没有严格使用对象类型的痛苦世界.
Well it turns out its a Sandbox Issue. Files that are not part of the installer are placed in a different Security Sandbox, and since they reside in different sandboxes, the child when imported into the parent does not inherit the definitions of its Parent in the ApplicationDomain
and two separate definitions exist which are incompatible. Sadly, there seems to be no direct way of resolving this. Adobe does allow communication between sandboxes via the SandBoxBridge, but that forces you to use Object type, which kind of defeats the purpose of the whole thing. As far as i can tell there is no way for classes in two different sandboxes to be compatible even though they are exactly the same. I guess its back the painfull world of no strict typing with Objects.
这篇关于在父子 SWF 之间共享类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!