FLEX : Event 事件

[color=red][size=medium][b]ActionScript 3.0 Developer’s Guide / Core ActionScript Classes -> Handling events:
[url]http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7fca.html[/url]
Using Flex 4.5 / Getting started -> Events:
[url]http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7ee9.html[/url]
Event Propagation:
[url]http://learn.adobe.com/wiki/display/Flex/Event+Propagation[/url][/b][/size][/color]


[b]Event-driven programming in Flex with Custom Events:
[url]http://flexblog.faratasystems.com/2007/02/26/event-driven-programming-in-flex-with-custom-events[/url]
An indepth look at Flex Events:
[url]http://codeofdoom.com/wordpress/2009/03/02/an-indepth-look-at-flex-events/[/url][/b]


[size=medium][b]Attention:[/b][/size]
当在as代码中置Combobox的selectedItem/selectedIndex 、DateField的selectedDate时,如:
comboBox.selectedIndex = j;

dateField.selectedDate = actDate;

并不会分发change事件!所以需要硬编码分发change event:
comboBox.selectedIndex = j;
comboBox.dispatchEvent(new IndexChangeEvent(IndexChangeEvent.CHANGE));

dateField.selectedDate = actDate;
dateField.dispatchEvent(new CalendarLayoutChangeEvent(CalendarLayoutChangeEvent.CHANGE));



绝好的一个理解FLEX事件的例子:华氏/摄氏温度转换类 DegreeConverter :
[url]http://www.artima.com/articles/two_way_binding.html[/url][quote]
package com.artima {
import flash.events.Event;
import flash.events.EventDispatcher;

[Bindable]
public class DegreeConverter extends EventDispatcher {

private var fahrenheitDegree: Number;
private var celsiusDegree: Number;

public function set fahrenheit(n: Number): void {
fahrenheitDegree = n;
celsiusDegree = (fahrenheitDegree - 32) * 5/9;
dispatchEvent(new Event("celsiusChanged", true, true));
}

[Bindable(event="fahrenheitChanged")]
public function get fahrenheit(): Number {
return fahrenheitDegree;
}

public function set celsius(n: Number): void {
celsiusDegree = n;
fahrenheitDegree = celsiusDegree * 9/5 + 32;
dispatchEvent(new Event("fahrenheitChanged", true, true));
}

[Bindable(event="celsiusChanged")]
public function get celsius(): Number {
return celsiusDegree;
}
}
}
[/quote]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值