Flex:发送参数给Alert closeHandler [英] Flex: Sending parameters to Alert closeHandler

查看:187
本文介绍了Flex:发送参数给Alert closeHandler的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将参数发送到closeHandler警报功能?
函数获得的fisrt参数是CloseEvent,但是如何发送另一个?

 < s:Button id =btnLoadLocalDatalabel =加载数据
click =Alert.show('用本地数据填充列表?','Alert.YES | Alert.CANCEL,this,loadLocalData ),null,Alert.OK);/>

谢谢!

解决方案

这应该可以使用Flex的动态函数构造。一个类似的问题被问到这里



下面是一个例子:

参数和处理程序:

  var parameters:String =我想传递的某个参数; 

private function loadLocalData(e:Event,parameter:String):void
{
// voila,这里是你的参数
}
$ b $ ()方法:函数
{
return function(event:Event):void {method.apply(null,[event] .concat(additionalArguments)); }

您的组件:

 < s:按钮id =btnLoadLocalDatalabel =加载数据
click =Alert.show('填充列表本地数据?,Alert.YES | Alert.CANCEL,this,addArguments(loadLocalData,[parameters])),null,Alert.OK);/>


Is it possible to send parameters to a closeHandler Alert function? The fisrt parameter the function gets is the CloseEvent, but how to send another one?

<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);"/>

Thank you!

解决方案

This should be possible using Flex's dynamic function construction. A similar question was asked here.

Here's an example:

The parameters and handler:

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));}
}

Your component:

<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);"/>

这篇关于Flex:发送参数给Alert closeHandler的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆