FLEX : Event 事件

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



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



Attention:
当在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 :
http://www.artima.com/articles/two_way_binding.html
引用
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;
    }
  }
}

你可能感兴趣的:(sql,Flex)