flex 3:使用警报窗口将值传递给函数
我有一个函数可以在用户单击按钮时检查某些内容。如果发现某物,则会出现一条警报,表示已找到该物,并询问他们是否愿意允许这种情况发生,或撤消导致该物被发现的操作。代码如下所示:
Alert.show(thisString1, "Conflict: Multiple Projects", 3, this, conflictAnswer);
按“是”或“否”后,将调用conflictAnswer函数...它看起来像这样:
private function conflictAnswer(event:CloseEvent):void
{
if (event.detail == Alert.YES)
{
Alert.show(
}
}
我的问题是,我将如何传递显示函数中保存的一些变量警报?我尝试过这样的事情:
Alert.show(thisString1, "Conflict: Multiple Projects", 3, this, conflictAnswer(Event, var1, var2));
private function conflictAnswer(event:CloseEvent, varA, varB):void
{
if (event.detail == Alert.YES)
{
}
}
但没有成功。
有人可以帮我吗?
谢谢 Brds
编辑 阅读第一个响应后,我想出了这个:
answers[0] = cPositions[i][0];
answers[1] = cPositions[i][1];
var anAlert:Alert = Alert.show(thisString1, "Conflict: Multiple Projects", 3, this, conflictAnswer);
anAlert.data = {answers:Array};
然后conflictAnswer函数看起来像这样:
private function conflictAnswer(event:CloseEvent):void
{
var projectID:Number = event.currentTarget.answers[0];
var positionID:Number = event.currentTarget.answers[1];
if (event.detail == Alert.YES)
{
Alert.show(String(projectID + " | " + positionID));
}
}
但这不起作用......有什么想法吗?
I have a function that checks for something when the user clicks a button. if that something is found, an alert comes up saying that it has been found and asks them if they would like to allow this to happen, or undo the action that caused the something to be found. the code looks like this:
Alert.show(thisString1, "Conflict: Multiple Projects", 3, this, conflictAnswer);
upon pressing "Yes" or "No", the conflictAnswer function will be called... it looks like this:
private function conflictAnswer(event:CloseEvent):void
{
if (event.detail == Alert.YES)
{
Alert.show(
}
}
My question is this, how would i pass some variables that are held in the function that displays the Alert? i tried something like this:
Alert.show(thisString1, "Conflict: Multiple Projects", 3, this, conflictAnswer(Event, var1, var2));
private function conflictAnswer(event:CloseEvent, varA, varB):void
{
if (event.detail == Alert.YES)
{
}
}
but it didn't work.
Can anybody help me out?
Thanks
Brds
EDIT
After reading the first respond, i've come up with this:
answers[0] = cPositions[i][0];
answers[1] = cPositions[i][1];
var anAlert:Alert = Alert.show(thisString1, "Conflict: Multiple Projects", 3, this, conflictAnswer);
anAlert.data = {answers:Array};
and then the conflictAnswer function looks like this:
private function conflictAnswer(event:CloseEvent):void
{
var projectID:Number = event.currentTarget.answers[0];
var positionID:Number = event.currentTarget.answers[1];
if (event.detail == Alert.YES)
{
Alert.show(String(projectID + " | " + positionID));
}
}
but this isn't working... any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Alert.show()
返回一个警报实例,其中包含data
字段,您可以在其中设置数据:然后在事件处理程序中,您可以获取数据对象:
对于您的代码,它将如下所示:
然后:
Alert.show()
returns an alert instance which hasdata
field where you can set your data:Then in event handler you can get your data object:
For your code it will look like the following:
and then: