2013-01-15 38 views
0

是否有一種簡單的方法來交換遞增和遞減按鈕行爲? 所以向上箭頭減小了值,向下箭頭增加了它。Flex spark spinner,交換箭頭行爲

+0

看一看我給這個[提問]答案(http://stackoverflow.com/questions/13975457/accessing-currentcssstate-property-on-event-target-incrementbutton/13976741#13976741) 。您可以擴展微調控制器來執行此操作。我鏈接的問題與你所問的不同,但答案應該對你有所幫助。另一種方法可能是爲Spinner製作自己的皮膚。如果您覺得它有幫助,請隨意投票回答:) –

+2

我正在建議創建自己的皮膚;並切換向下箭頭和向上箭頭按鈕的名稱。 – JeffryHouser

+0

自定義皮膚解決方案對我來說似乎是最簡單和最透明的。 – RIAstar

回答

1

這個火花微調元件的外殼解決了這個問題。我顛倒了皮膚類屬性和自上而下的屬性值。

<?xml version="1.0" encoding="utf-8"?> 

<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" 
    xmlns:fb="http://ns.adobe.com/flashbuilder/2009" alpha.disabled="0.5" minHeight="23" minWidth="12"> 

    <fx:Metadata> 
    <![CDATA[ 
     /** 
     * @copy spark.skins.spark.ApplicationSkin#hostComponent 
     */ 
     [HostComponent("spark.components.Spinner")] 
    ]]> 
    </fx:Metadata> 

    <fx:Script fb:purpose="styling"> 
     /* Define the skin elements that should not be colorized. 
      For spinner, the skin itself is colorized but the individual parts are not. */ 
     static private const exclusions:Array = [ "incrementButton","decrementButton",]; 

     /** 
     * @private 
     */ 
     override public function get colorizeExclusions():Array {return exclusions;} 

     /** 
     * @private 
     */ 
     override protected function initializationComplete():void 
     { 
      useChromeColor = true; 
      super.initializationComplete(); 
     } 

     private var cornerRadiusChanged:Boolean; 

     /** 
     * @private 
     */ 
     override protected function commitProperties():void 
     { 
      super.commitProperties(); 

      if (cornerRadiusChanged) 
      { 
       var cr:Number = getStyle("cornerRadius"); 
       if (incrementButton) 
        incrementButton.setStyle("cornerRadius", cr); 
       if (decrementButton) 
        decrementButton.setStyle("cornerRadius", cr); 
      } 
     } 

     /** 
     * @private 
     */ 
     override public function styleChanged(styleProp:String):void 
     { 
      var allStyles:Boolean = !styleProp || styleProp == "styleName"; 

      super.styleChanged(styleProp); 

      if (allStyles || styleProp == "cornerRadius") 
      { 
       cornerRadiusChanged = true; 
       invalidateProperties(); 
      } 
     } 
    </fx:Script> 

    <s:states> 
     <s:State name="normal" /> 
     <s:State name="disabled" /> 
    </s:states> 



    <!--- decrement button with increment skin --> 
    <s:Button id="decrementButton" left="0" right="0" top="0" height="50%" tabEnabled="false" 
       skinClass="spark.skins.spark.SpinnerIncrementButtonSkin" /> 

    <!--- increment button with decrement skin --> 
    <s:Button id="incrementButton" left="0" right="0" bottom="0" height="50%" tabEnabled="false" 
       skinClass="spark.skins.spark.SpinnerDecrementButtonSkin" /> 



</s:SparkSkin>