Flex中使用currentStateChange事件监听State变化

Categories: Flex; Tagged with: ; @ October 9th, 2010 0:12

StateChangeEvent.CURRENT_STATE_CHANGE(currentStateChange):
StateChangeEvent 类代表当组件的 currentState 属性更改时调度的事件。

中文API: http://www.adobe.com/livedocs/flex/3_cn/mx/events/StateChangeEvent.html

使用方法:

1. ActionScript中监听Event

ui.addEventListener(StateChangeEvent.CURRENT_STATE_CHANGE, onCurrentStateChange);

注意: 如果用在主程序Application creationComplete的响应方法中, 可能无法监听首个StateChange事件(进入初始State);

2. MXML中监听Event

currentStateChange="onCurrentStateChange(event)"

附录: 响应函数

/** On State Change . */
protected function onCurrentStateChange(event:StateChangeEvent):void {
	printLog("LastState: " + event.oldState + "; currentState" + currentState);
}

Trace信息:

LastState: StateEmployeesList; currentStateStateDeptMgt

<->



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.