是否可以将参数发送到 closeHandler Alert 函数?
函数得到的第一个参数是CloseEvent,但是如何发送另一个呢?
<s:Button id="btnLoadLocalData" label="Load data"
click="Alert.show('Populate list with local data?', '', Alert.YES | Alert.CANCEL, this, loadLocalData(???parameters???), null, Alert.OK);"/>
谢谢!
最佳答案
这应该可以使用 Flex 的动态函数构造来实现。有人问了类似的问题 here .
下面是一个例子:
参数和处理程序:
var parameters:String = "Some parameter I want to pass";
private function loadLocalData(e:Event, parameter:String):void
{
// voila, here's your parameter
}
private function addArguments(method:Function, additionalArguments:Array):Function
{
return function(event:Event):void {method.apply(null, [event].concat(additionalArguments));}
}
您的组件:
<s:Button id="btnLoadLocalData" label="Load data"
click="Alert.show('Populate list with local data?', '', Alert.YES | Alert.CANCEL, this, addArguments(loadLocalData, [parameters])), null, Alert.OK);"/>
关于apache-flex - 弹性 : Sending parameters to Alert closeHandler,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5071468/