Flex4中,弹出窗口有两种:
Alert.show("balabalabala…");
PopUpManager.addPopUp([要弹出的控件],[父控件],[是否模态]);
第二种是我们最常使用的,却很容易出现问题(如题)。
出现的原因是因为使用了spark组件,因为spark组件没有removeChilde的方法,
所以就产生了异常。这是adobe的BUG,目前还没解决。
规避的办法就是将需要弹出的控件放置在mx组件内部即可。
附原始英文解释:
There is a problem in Flex 4 when you using the PopUpManager's addPopUp() method to
create a pop up that has a Spark container parent. This problem was reported in a JIRA bug:
SDK-25082. If you call addPopUp(), you will get the runtime error:
Error: removeChild() is not available in this class. Instead, use removeElement() or modify
the skin, if you have one.
at spark.components::Group/removeChild()
Unfortunately, we didn't have time to fix this bug in the Flex 4 time frame. So, the bug was
deferred. However, there is a pretty simple workaround for the bug. In your code, you just
need to parent the component that you want to pop up with an MX component.