ApplicationDomain中clarifiation需要ApplicationDomain、clarifiation

2023-09-08 14:09:50 作者:跟自己说声对不起。

我需要对这个问题的一些澄清,我只是遇到了一个问题,主权财富基金加载到一个重复使用Loader对象。

I need some clarification on this subject as I just ran into an issue with loading swfs into a reused loader object.

因此​​,可以说我有3个主权财富基金。 main.swf中 childA.swf childB.swf

So lets say I have 3 SWFs. Main.swf childA.swf childB.swf

的main.swf中有一个加载器对象得到重用(myloader.load(childA.swf))和childA或childB SWF将通过用户交互来加载。 这两个孩子主权财富基金有一个COM封装类中的呼包配置。 该配置文件是为两个类只是同名不同的文件。 这两个子SWF也派遣一个事件,主要用于监听

Main.swf has a loader object in it that gets reused (myloader.load("childA.swf")) and childA or childB swf will be loaded via user interaction. Both child swfs have a com package with a class in that package called config. The config files are different files for both classes just named the same. both child swf also dispatch an event that the Main listens for

现在的问题,我如果是载childA先再经过childB装入它仍然显示为childA。基本上,哪一个得到加载到装载机第一是赢家。 这驱使我坚果如无物我做将导致SWF卸载。直到我发现下面的code。

Now the problem I had was if childA was loaded first then after childB was loaded it would still show as childA. Basically, whichever one got loaded into that loader first would be the winner. This drove me nuts as nothing I did would cause the swf to unload. Not until I found the following code.

var appDomain:ApplicationDomain = new ApplicationDomain();
var context:LoaderContext = new LoaderContext(false, appDomain);
_contentPanel.load(new URLRequest(str), context);

我偶然发现了这个code在职位地方谈到如何真正卸载瑞士法郎。显然,这也适用于如何真正加载SWF。 正如你可以看到一个新的AppDomain被创建,加载时分配到上下文。 这就像一个梦我现在可以装载和卸载整天。

I stumbled over this code on a post somewhere talking about how to truly unload a swf. Apparently, This also applies to how to truly load a swf. As you can see a new appDomain is created and assigned to the context when loaded. This works like a dream I can now load and unload all day long.

我的困惑是事件,孩子分派仍然有效,当我不认为主SWF应该把它捡起来,由于它在相同的AppDomain不是。 我的意思是不应该的事件被阻止?

My confusion is the event that the child dispatches still works, when I don't think the Main swf should pick it up due to it not being in the same appDomain. I mean shouldn't the event be blocked?

推荐答案

卸载的SWF

Loader类提供了 Loader.unload()(或Flash Player VERS后10 - Loader.unloadAndStop()

The Loader class provides Loader.unload() (or after Flash Player vers. 10 - Loader.unloadAndStop())

与第二加载的SWF问题由覆盖第一个

存储在的ApplicationDomain 的S对象按其类名保存,我不知道加载的主权财富基金(或子女)的类名是否覆盖。即使不是这种情况;为什么不使用装载机的一个新的实例被加载的每个对象?

Objects that are stored in ApplicationDomains are stored by their class-name and I wonder whether the class names of the loaded SWFs (or their children) are overriding. Even if that isn't the case; why not use a new instance of the Loader for each object being loaded?

如何在主SWF可以拿起从另一个应用程序域两个孩子

主SWF将能够与新的(加载)的应用领域工作,因为他们的孩子域的主SWF的(见ApplicationDomain.parentDomain)。主SWF的域将成为系统域和新的实例将它下面被加载。

The Main SWF will be able to work with the new (loaded) application domains because they are child-domains of the Main SWF's (See ApplicationDomain.parentDomain). The Main SWF's domain will be the 'system domain' and the new instances will be loaded below it.

从Loader拆分加载的SWF

在理想情况下,你要访问的SWF数据不相关的装载机的状态。您可以通过访问一次加载的SWF的根影片剪辑做到这一点,以创建一个新的实例

Ideally you want to have access to the SWF data irrelevant of the state of the Loader. You can do this by accessing the root movieClip of the SWF once loaded and create a new instance with

var rootClipClass:Class = ApplicationDomain.getDefinition("[InsertYourRootClipName]") as Class; 
var rootClip:MovieClip = new rootClipClass(); 

在这一点上,你可以卸载装载机和你的新鲜干净的实例工作。

At that point you can unload the loader and work with your fresh instance cleanly.

进一步阅读

Loader.unload()和装载机的差异。 unloadAndStop() 使用应用程序域工作 - 的Adobe文档 装载机类的引用 ApplicationDomain类参考 Difference between Loader.unload() and Loader.unloadAndStop() Working with Application Domains - Adobe Docs Loader class reference ApplicationDomain class reference
相关推荐