开发者

parentDomain of sibling ApplicationDomains not equal... how & why

开发者 https://www.devze.com 2023-01-31 00:11 出处:网络
How can same be false in the following snippet? var child1:Application开发者_如何学运维Domain = new ApplicationDomain(ApplicationDomain.currentDomain);

How can same be false in the following snippet?

var child1:Application开发者_如何学运维Domain = new ApplicationDomain(ApplicationDomain.currentDomain);
var child2:ApplicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);

var same:Boolean = (child1.parentDomain === child2.parentDomain);
trace(same);


You're using the strict equality operator and you're creating two new objects, even though they share some property which is the currentDomain that is passed as an argument to the constructor they are not the same object, if you were to first create

var temp:ApplicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);

then assigned this as child1 and child2 then check their parentDomains against one another I would bet you'd get a different result. I would throw a breakpoint in there and look at the memory addresses of both the child1/child2 as well as child1.parentDomain and child2.parentDomain (in the debug panel) in order to determine what's really happening here, unfortunately the ApplicationDomain object is part of the closed source portion of Flash.

0

精彩评论

暂无评论...
验证码 换一张
取 消