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

相关文章

一:display:flex布局display:flex是一种布局方式。它即可以...
1. flex设置元素垂直居中对齐在之前的一篇文章中记载过如何...
移动端开发知识点pc端软件和移动端apppc端软件是什么,有哪些...
最近挺忙的,准备考试,还有其他的事,没时间研究东西,快周...
display:flex;把容器设置为弹性盒模型(设置为弹性盒模型之后...
我在网页上运行了一个Flex应用程序,我想使用Command←组合键...