我正在创建一个库.这是一个例子
[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"));
}
Run Code Online (Sandbox Code Playgroud)
我在app端有一个听众.因此,当我手动调度事件时,我希望将"ob"作为参数发送.怎么做?
Jam*_*Hay 20
您需要创建一个具有额外属性的自定义事件类,以便使用它传递数据.在你的情况下,你可以使用类似的类
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);
}
}
Run Code Online (Sandbox Code Playgroud)
然后当你发送时:
dispatchEvent(new YourEvent(YourEvent.SOMETHING_HAPPENED, ob));
Run Code Online (Sandbox Code Playgroud)
小智 5
在AS3中,您可以使用DataEvent:
例如:
dispatchEvent(new DataEvent(type:String [,bubbles:Boolean = false,cancelable:Boolean = false,data:String]);
我展示了DataEvent所采用的参数,而不是示例数据.
我希望这有帮助.
最好的问候,RA.
| 归档时间: |
|
| 查看次数: |
16385 次 |
| 最近记录: |