flash on 2010-11-20

by Nowloading_
♥0 | Line 84 | Modified 2010-11-20 23:39:43 | MIT License
play

ActionScript3 source code

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

package{
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.events.TimerEvent;
    import flash.utils.Timer;
    
    [SWF(width = 300, height = 240,backgroundColor=0xffffff)]
    public class RampSample extends Sprite{
        private var betRamp:Sprite;
        private var replayRamp:Sprite;
        private var startRamp:Sprite;
        private var ramp1:ramp;
        private var ramp2:ramp;
        private var ramp3:ramp;
        private var rampCount:int = 0;
        
        private var r1clr:uint = 0xff0000;
        private var r2clr:uint = 0x00ff00;
        private var r3clr:uint = 0x0000ff;
        
        private var _mode:int = 0;
        private var _betMode:int = 0;
        private var _countUp:int = 0;
        private var _count:int = 0;

        private var _tim:Timer;
        
////////////////////////////////////////////////////

        public function RampSample(){
            
            ramp1 = new ramp(r1clr);
            ramp2 = new ramp(r2clr);
            ramp3 = new ramp(r3clr);
            addChild(ramp1);
            addChild(ramp2);
            ramp2.y=17;
            addChild(ramp3);
            ramp3.y = 34;
            _tim = new Timer(33,3)
            stage.addEventListener(MouseEvent.CLICK, cri);
        }
        
        public function cri(e:MouseEvent):void{
            if(_mode == 0){
                _tim.reset();
                _tim.addEventListener(TimerEvent.TIMER, timhandler1);
                _tim.start();
            }else if (_mode ==1){
                _mode = 2;
            }else if (_mode == 2){
                ramp1.lightOff();
                ramp2.lightOff();
                ramp3.lightOff();
                _mode = 0;
            }
        }
        private function timhandler1(e:TimerEvent):void{
            if(rampCount == 0){
                ramp1.lightOn();
                rampCount = 1;
            } else if (rampCount ==1){
                ramp2.lightOn();
                rampCount = 2;
            } else if(rampCount ==2){
                ramp3.lightOn();
                rampCount = 0;
                _tim.removeEventListener(TimerEvent.TIMER,timhandler1);
                _mode = 1;
            }
        }
    }
}

////////////////////////////////////////////////////

//ベットランプ用クラス
import flash.display.Sprite;
class ramp extends Sprite{
    private var _over:Sprite;
    public function ramp(clr:uint){
        graphics.beginFill(clr);
        graphics.drawRoundRect(100,150,20,14,5);
        graphics.endFill();
        
        _over = new Sprite();
        _over.graphics.beginFill(0x333333);
        _over.graphics.drawRoundRect(100,150,20,14,5);
        _over.graphics.endFill();
        addChild(_over);
    }
        public function lightOn():void{
        _over.visible = false;
    }
    //マウスオーバー時の表示
    public function lightOff():void{
        _over.visible = true;
    }    
}