Flex:removedEffect 在更改父级时会导致错误
好的,我有一个带有此方法的 TitleWindow
子类:
public function launchInNewWindow(e:Event):void
{
this.parent.removeChild(this);
ownWindow = new Window();
ownWindow.systemChrome = 'none';
ownWindow.type = NativeWindowType.LIGHTWEIGHT;
ownWindow.transparent = true;
ownWindow.setStyle('showFlexChrome', false);
ownWindow.width = this.width > 750 ? 750 : this.width;
ownWindow.height = this.height > 550 ? 550 : this.height;
edit.enabled = false;
ownWindow.addChild(this);
ownWindow.width += 5; //add to show dropshadow
ownWindow.height += 10; //add to show dropshadow
ownWindow.open();
_inOwnWindow = true;
ownWindow.nativeWindow.x = Application.application.nativeWindow.x + this.x + 5; //keep in same spot add 5 for systemChrom border
ownWindow.nativeWindow.y = Application.application.nativeWindow.y + this.y + 30;//keep in same spot add 30 for systemChrom title
}
它的作用是通过创建一个新的 Window 对象并将其自身添加到标题窗口,使其成为自己的 Window
(NativeWindow)新窗口的显示列表。
它工作得非常好,但是如果我在此类的实例上设置了 removedEffect
,则在尝试将自身添加到 Window 的 displayList 时会产生错误。
我尝试在该方法中添加:
this.setStyle('removedEffect',null);
和,
this.setStyle('removedEffect',new TitleWindow().getStyle('removedEffect'));
以尝试事先删除对其自身设置的任何removedEffect,但没有成功。
但如果组件上没有removedEffect,它就可以正常工作。必须有办法解决这个问题。
有什么想法吗?
谢谢!!
ok I have a subclass of TitleWindow
with this method:
public function launchInNewWindow(e:Event):void
{
this.parent.removeChild(this);
ownWindow = new Window();
ownWindow.systemChrome = 'none';
ownWindow.type = NativeWindowType.LIGHTWEIGHT;
ownWindow.transparent = true;
ownWindow.setStyle('showFlexChrome', false);
ownWindow.width = this.width > 750 ? 750 : this.width;
ownWindow.height = this.height > 550 ? 550 : this.height;
edit.enabled = false;
ownWindow.addChild(this);
ownWindow.width += 5; //add to show dropshadow
ownWindow.height += 10; //add to show dropshadow
ownWindow.open();
_inOwnWindow = true;
ownWindow.nativeWindow.x = Application.application.nativeWindow.x + this.x + 5; //keep in same spot add 5 for systemChrom border
ownWindow.nativeWindow.y = Application.application.nativeWindow.y + this.y + 30;//keep in same spot add 30 for systemChrom title
}
What this does is make the title window its own Window
(NativeWindow) by creating a new Window object and adding itself to the new Window's displayList.
It works really well, however if I have a removedEffect
set on the instance of this class it produces an error when trying to add itself to the Window's displayList.
I tried adding:
this.setStyle('removedEffect',null);
and
this.setStyle('removedEffect',new TitleWindow().getStyle('removedEffect'));
to the method as an attempt to remove any removedEffect set on itself before hand, but with no luck.
but it works fine if there is no removedEffect on the component. There has got to be a way to fix this.
Any ideas?
Thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要使
removedEffect
正常工作,窗口需要位于原始父级上,但您立即尝试将其添加到新父级,并且它不能同时属于两个父级。我能想到几个选择。获取要删除的窗口的位图,显示在同一位置,在此位图副本上运行您想要的效果,然后您可以在不受效果干扰的情况下运行重新设置原始窗口的父级。
将删除和重新设置父级的代码分为两个步骤。先把窗户拆掉。然后,当
removedEffect
完成后,将其添加到新窗口的显示列表中。For the
removedEffect
to work the window needs to be on the original parent, but you're immediately trying to add it to the new parent and it can't belong to two parents at once. There are a few options I can think of.Get a bitmap of the window to be removed, show that in the same place, run the effect you want on this bitmap copy, and then you can run re-parent the original without interference from the effect.
Separate the code that removes and re-parents into two steps. Remove the window first. Then when the
removedEffect
is done, add it to the new window's display list.