日期:2014-05-16 浏览次数:20427 次
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.binding.utils.BindingUtils;
private var num:Number = 0;
private var styleArr:Array =[];
internal function init():void{
styleArr.push("Button Click");
styleArr.push("Hslider Value");
cmbStyle.dataProvider = styleArr;
}
internal function setProValue(num:Number):void{
trace("num:"+num);
testProBar.setProgress(num,1000);
}
internal function clickPro():void{
//trace(cmbStyle.selectedIndex);
trace(num);
//手动模拟
if(num<= 1000){
setProValue(num);
num+=100;
}
if(num>1000){
num = 0;
}
}
internal function styleChange():void{
if(cmbStyle.selectedIndex == 1){
startbtn.enabled = false;
dragHs.enabled = true;
//BindingUtils实现数据绑定
BindingUtils.bindSetter(setProValue,dragHs,"value");
}
else{
startbtn.enabled = true;
dragHs.enabled = false;
}
}
]]>
</mx:Script>
<mx:Button id="startbtn" x="217" y="97" label="开始" fontSize="12" click="clickPro()"/>
<mx:Label x="311" y="97" text="方式:" height="22" fontSize="12" color="#F64515"/>
<mx:ProgressBar id="testProBar" x="217" y="171" width="277" color="#47D140" labelPlacement="center" height="30"/>
<mx:HSlider id="dragHs" x="217" y="272" width="277"/>
<mx:ComboBox id="cmbStyle" x="360" y="97" width="134" change="styleChange()"></mx:ComboBox>
</mx:Application>