小小菜鸟的web菜园子

web开发学习。好记性不如烂笔头。每天进步一点点!

导航

设置NumericStepper控件获得焦点时的边框透明度.

NumericStepper控件的focusAlpha样式学习.
示例:

代码:

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/05/23/setting-the-focus-alpha-on-a-numericstepper-control-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout
="vertical"
        verticalAlign
="middle"
        backgroundColor
="white">

    
<mx:Script>
        
<![CDATA[
            import mx.events.NumericStepperEvent;

            private function numericStepper_change(evt:NumericStepperEvent):void {
                // reset focus
                focusManager.setFocus(btn);
                focusManager.setFocus(numericStepper);
            }
        
]]>
    
</mx:Script>

    
<mx:ApplicationControlBar dock="true">
        
<mx:Button id="btn" label="click here to remove focus" />
    
</mx:ApplicationControlBar>

    
<mx:NumericStepper id="numericStepper"
            minimum
="0.0"
            maximum
="1.0"
            value
="0.5"
            stepSize
="0.1"
            textAlign
="center"
            focusAlpha
="{numericStepper.value}"
            change
="numericStepper_change(event);" />

</mx:Application>

你也可以通过CSS设置:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/05/23/setting-the-focus-alpha-on-a-numericstepper-control-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout
="vertical"
        verticalAlign
="middle"
        backgroundColor
="white">

    
<mx:Style>
        NumericStepper {
            focusAlpha: 1.0;
        }
    
</mx:Style>

    
<mx:ApplicationControlBar dock="true">
        
<mx:Button id="btn" label="click here to remove focus" />
    
</mx:ApplicationControlBar>

    
<mx:NumericStepper id="numericStepper"
            minimum
="0.0"
            maximum
="1.0"
            value
="1.0"
            stepSize
="0.1"
            textAlign
="center"/>

</mx:Application>

你也可以通过AS设置:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/05/23/setting-the-focus-alpha-on-a-numericstepper-control-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout
="vertical"
        verticalAlign
="middle"
        backgroundColor
="white">

    
<mx:Script>
        
<![CDATA[
            import mx.events.NumericStepperEvent;

            private function numericStepper_change(evt:NumericStepperEvent):void {
                numericStepper.setStyle("focusAlpha", evt.value);
                // reset focus
                focusManager.setFocus(btn);
                focusManager.setFocus(numericStepper);
            }
        
]]>
    
</mx:Script>

    
<mx:ApplicationControlBar dock="true">
        
<mx:Button id="btn" label="click here to remove focus" />
    
</mx:ApplicationControlBar>

    
<mx:NumericStepper id="numericStepper"
            minimum
="0.0"
            maximum
="1.0"
            value
="0.5"
            stepSize
="0.1"
            textAlign
="center"
            change
="numericStepper_change(event);" />

</mx:Application>

posted on 2008-05-26 12:54  『小小菜鸟』  阅读(394)  评论(0编辑  收藏  举报