要发送自定义调度事件参数 [英] Want to send parameters with custom dispatch event
本文介绍了要发送自定义调度事件参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建一个图书馆。下面是一个例子
I am creating a library. Here is an example
[Event (name="eventAction", type="something")]
public function create_new_customer(phone_number:String):void
{
-------------;
----;
------------;
rpc.addEventListener(Event.COMPLETE, onCreate_returns);
}
private function onCreate_returns(evt:Event):void
{
var ob:Object = evt.target.getResponse();
dispatchEvent(new something("eventAction"));
}
我有一个监听器此事件在应用程序的一面。所以,当我手动调度事件我想要的 肥胖被作为参数发送。怎么办呢?
I have a listener to this event in app side. So when I manually dispatch event I want the "ob" to be sent as a parameter. How to do it?
推荐答案
您需要创建额外的属性自定义事件类,它传递数据。你的情况,你可以使用一个类像
You need to create a custom event class with extra properties to pass data with it. In your case you could use a class like
public class YourEvent extends Event
{
public static const SOMETHING_HAPPENED: String = "somethingHappend";
public var data: Object;
public function YourEvent(type:String, data: Object, bubbles:Boolean=false, cancelable:Boolean=false)
{
super(type, bubbles, cancelable);
this.data = data;
}
override public function clone():Event
{
return new YourEvent (type, data, bubbles, cancelable);
}
}
然后当溜溜派遣你做的:
then when yo dispatch you do:
dispatchEvent(new YourEvent(YourEvent.SOMETHING_HAPPENED, ob));
这篇关于要发送自定义调度事件参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文