Flex 弹出窗口:堆栈溢出?
我以某种方式在 Flex 3 中创建了一个堆栈溢出...我试图从模式对话窗口中获取数据,如下所示:
Main application:
var myPopup:MyPopup;
function buttonClick( event:MouseEvent ):void
{
myPopup = MyPopup( PopUpManager.createPopUp( this, MyPopUp, true ) );
myPopup.addEventListener( CloseEvent.CLOSE, handler, false, 0, true );
}
function handler():void
{
//get data
}
MyPopup:
function buttonHandler( MouseEvent:event ):void
{
PopUpManager.remove( this );
this.dispatchEvent( new CloseEvent( CloseEvent.CLOSE ) );
}
If this is notproperty, what is the right way to close of the弹出窗口是否允许我使用和检索对象上的数据?
I'm somehow creating a stack overflow in Flex 3...I'm trying to get data out of a modal dialogue window as such:
Main application:
var myPopup:MyPopup;
function buttonClick( event:MouseEvent ):void
{
myPopup = MyPopup( PopUpManager.createPopUp( this, MyPopUp, true ) );
myPopup.addEventListener( CloseEvent.CLOSE, handler, false, 0, true );
}
function handler():void
{
//get data
}
MyPopup:
function buttonHandler( MouseEvent:event ):void
{
PopUpManager.remove( this );
this.dispatchEvent( new CloseEvent( CloseEvent.CLOSE ) );
}
If this is improper, what is the correct way to handle closing of the popup in a manner that allows me to use and retrieve data on the object?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
也许您可以尝试向处理程序添加事件参数。 我不太确定 ActionScript 是否总是可以容忍不提供这一点。 示例:
我还赞同贾斯汀提到的在关闭弹出窗口之前调用处理程序的做法。
Perhaps you could try adding an event parameter to your handler. I'm not so sure that ActionScript can always tolerate that not being provided. Example:
I also second the practice of calling the handler before dismissing the popup as mentioned by Justin.
我已经重新创建了您的代码,它对我来说工作得很好:(这意味着要么我误解了您的问题,要么错误在您的代码中的其他地方。
您有机会发布有关该问题的更多详细信息吗?
Sam
PS Here是我用来测试的代码:
Application.mxml:
Popup.mxml
I've recreated your code and it works fine for me :( This means that either I've misunderstood your problem or the bug is somewhere else in your code.
Any chance that you can post some more details about the problem?
Sam
PS Here is the code I used to test with :
Application.mxml :
Popup.mxml
您还需要创建一个处理函数来清理弹出窗口中的事件、模型等。 否则它不会被垃圾收集并减慢你的应用程序的速度。
You also need to create a dispose function to clean event, models etc... in your pop up. Otherwise it will not be garbage collected and slow down your app.
不能完全确定 PopUpManager 的行为方式,但您可能希望切换 buttonHandler 中的语句:
当您的事件代码运行时,弹出窗口将保持打开状态,但它应该处理在您之前处理弹出对象的情况触发尝试从中获取数据的代码。
Not absolutely certain on how the PopUpManager behaves, but you might want to switch the statements in your buttonHandler:
The popup will stay up while your event code is running, but it should take care of the situation where your popup object is being disposed before you fire the code that tries to get data from it.
在您的示例中,将
PopUpManager.removePopUp(this);
移至关闭事件处理程序,即popupClose(e:Event)
。 您还需要将参数this
替换为 popup。In your sample, move
PopUpManager.removePopUp(this);
to the close event handler, i.e.,popupClose(e:Event)
. You'll also need to replace the argumentthis
with popup.