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

Flex4 State itemCreationPolicy 设定State组件立即创建

Categories: Flex; Tagged with: ; @ October 7th, 2010 22:20

没怎么用过State, 据说Flex4中State有很大更新, 今天小用了下. 发现一个问题:

非Start State中的Component在Application Create complete后不能立即使用. 于是想到了之前常用的creationPolicy – 统统设置为ALL, 结果仍旧无济于事.

解决方法: 设定组件itemCreationPolicy="immediate".

(more…)



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