4,327
社区成员




<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.CloseEvent;
import mx.controls.Alert;
[Bindable]
private var comboDataProvider:ArrayCollection = new ArrayCollection(['A','B','C','D']);
private var isUpdate:Boolean = false;
private function changeHandler(event:Event):void{
isUpdate = true;
}
private function comboChangeHandler(event:Event):void{
if(isUpdate){
Alert.show("数据有改变,是否保存?","提示",Alert.OK|Alert.CANCEL,null,function(evt:CloseEvent):void{
if(evt.detail == Alert.OK){
isUpdate = false;
}else if(evt.detail == Alert.CANCEL){
trace(evt.cancelable);
evt.preventDefault();
}
});
}
}
]]>
</mx:Script>
<mx:ComboBox id="cb" dataProvider="{comboDataProvider}" click="comboChangeHandler(event)"/>
<mx:TextInput id="ti" text="Hello World" change="changeHandler(event)"/>
</mx:Application>