微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Flex 的一点总结1Flex事件

原文链接http://www.cnblogs.com/vincentradcliffe/archive/2010/11/08/1871877.html
  1. 事件抛出

protected function FileList_changeHandler(event:ListEvent):void

{

// 当用户点击列表中的数据项后,抛出加载影像的请求

var evt:LoadImageEvent=new LoadImageEvent(LoadImageEvent.EVENT_LOADIMAGE); evt.URL=URLList.getItemAt(event.rowIndex).toString();

this.dispatchEvent(evt);

}

2.事件定义

package com.gw.events

{

import flash.events.Event;

/*该事件用于向后台请求图像列表*/

public class WeatherEvent extends Event

{

public static const EVENT_IRFILELIST:String = "event_IRfilelist";//红外影像请求事件

public static const EVENT_3DFILELIST:String = "event_3Dfilelist";//3D影像请求事件

public static const EVENT_SARFILELIST:String = "event_SARfilelist";//SAR影像请求事件

public static const EVENT_WEATHERFILELIST:String = "event_Weatherfilelist";//天气影像请求事件

public static const EVENT_JAPANFILELIST:String = "event_Japanfilelist";//日本预报图影像请求事件

public static const EVENT_EUROPEFILELIST:String = "event_Europefilelist";//欧洲预报图影像请求事件

public static const EVENT_MM5FILELIST:String = "event_MM5filelist";//MM5影像请求事件

public static const EVENT_GETCURRENTPAGE:String = "event_getcurrentpage";

public var startDate:String;

public var endDate:String;

public var fileType:String;

public function WeatherEvent(type:String, bubbles:Boolean=true, cancelable:Boolean=true)

{

//Todo: implement function

super(type, bubbles, cancelable);

}

}

}

*bubbles一定要为TRUE 否则事件不冒泡。

3.控件自定义事件

<mx:Metadata>

[Event(name="event_getcurrentpage", type="com.gw.events.WeatherEvent")]

[Event(name="event_loadimage", type="com.gw.events.LoadImageEvent")]

</mx:Metadata>

4.控件事件绑定

pictureShower=new TitleWindow;

pictureShower.addEventListener(CloseEvent.CLOSE,PictureShowerCloseWindow);

5.Mate事件地图机制

<services:ROService id="services" />

<EventHandlers type="{WeatherEvent.EVENT_IRFILELIST}" start="trace('EVENT_IRFILELIST started!')" end="trace('EVENT_IRFILELIST ended!')" debug="true">

<RemoteObjectInvoker instance="{services.weatherService}" method="getIRcloudbyDate" arguments="{[event.startDate,event.endDate]}">

<resultHandlers>

<MethodInvoker generator="{SelectimagePanelControl}" method="ProsingIR" arguments="{resultObject}" />

</resultHandlers>

</RemoteObjectInvoker>

</EventHandlers>

6.Mate注入机制

在事件地图中:

<Injectors target="{SelectimagePanel}" debug="true">

<PropertyInjector targetKey="fileList" source="{SelectimagePanelControl}" sourceKey="fileList" />

<PropertyInjector targetKey="URLList" source="{SelectimagePanelControl}" sourceKey="URLList" />

</Injectors>

将SelectimagePanelControl的fileList注入到SelectimagePanel的fileList。

在SelectimagePanel定义要绑定。

[Bindable]

public var fileList:ArrayCollection;

[Bindable]

public var URLList:ArrayCollection;

7.错误处理

事件地图中:

<EventHandlers type="{UnhandledFaultEvent.FAULT}">

<MethodInvoker generator="{GenericFaultHandler}" method="displayMessage" arguments="{event.fault}" />

</EventHandlers>

转载于:https://www.cnblogs.com/vincentradcliffe/archive/2010/11/08/1871877.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐