mx.controls.Button のステートを無理矢理変更するサンプル

by taiga
♥0 | Line 34 | Modified 2009-06-03 16:19:02 | MIT License
play

ActionScript3 source code

/**
 * Copyright taiga ( http://wonderfl.net/user/taiga )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/rYg7
 */

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal">
<!---
mx.controls.Button のステートを無理矢理変更するサンプル
@author taiga
-->

    <mx:Script>
        <![CDATA[
            import mx.controls.ButtonPhase;
            public function showUpState():void {
                targetButton.enabled = true;
                targetButton.mx_internal::phase = ButtonPhase.UP;
            }
            public function showOverState():void {
                targetButton.enabled = true;
                targetButton.mx_internal::phase = ButtonPhase.OVER;
            }
            public function showDownState():void {
                targetButton.enabled = true;
                targetButton.mx_internal::phase = ButtonPhase.DOWN;
            }
            public function showDisabledState():void {
                targetButton.enabled = false;
            }
        ]]>
    </mx:Script>

    <mx:Button id="targetButton" width="200" height="110" />

    <mx:VBox verticalGap="10">
        <mx:Button label="up state"       width="200" height="20" textAlign="left" click="showUpState()" />
        <mx:Button label="over state"     width="200" height="20" textAlign="left" click="showOverState()" />
        <mx:Button label="down state"     width="200" height="20" textAlign="left" click="showDownState()" />
        <mx:Button label="disabled state" width="200" height="20" textAlign="left" click="showDisabledState()" />
    </mx:VBox>

</mx:Application>