Spriteで扇風機

by yuugurenote
青スイッチでON。
赤スイッチでOFF。
♥0 | Line 151 | Modified 2012-06-17 15:45:08 | MIT License
play

ActionScript3 source code

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

package {
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.events.Event;
    [SWF(width=465,height=465,backgroundColor=0xFFFFFF,frameRate=60)]
    public class AS120617_01 extends Sprite {
        public var sw:Number=stage.stageWidth;
        public var sh:Number=stage.stageHeight;
        public var _myCircle1:myCircle1;
        public var _myCircle2:myCircle2;
        public var _myCircle3:myCircle3;
        public var _myCircle4:myCircle2;
        public var _myRect1:myRect1;
        public var _myRect2:myRect2;
        public var _myRect3:myRect3;
        public var _myHane1:myHane;
        public var _myHane2:myHane;
        public var _myHane3:myHane;
        public var _myHane4:myHane;
        public var _myFlag:Boolean=false;
        public var _myRot:Number=0;

        public function AS120617_01() {

            _myCircle1=new myCircle1  ;
            _myCircle1.x=sw/2;
            _myCircle1.y=120;
            addChild(_myCircle1);

            _myCircle2=new myCircle2  ;
            _myCircle2.x=sw/2;
            _myCircle2.y=120;
            addChild(_myCircle2);

            _myCircle3=new myCircle3  ;
            _myCircle3.x=sw/2-73;
            _myCircle3.y=370;
            addChild(_myCircle3);

            _myCircle4=new myCircle2  ;
            _myCircle4.x=sw/2;
            _myCircle4.y=120;
            addChild(_myCircle4);

            _myRect1=new myRect1  ;
            _myRect1.x=sw/2-7.5;
            _myRect1.y=210;
            addChild(_myRect1);

            _myRect2=new myRect2  ;
            _myRect2.x=sw/2-35;
            _myRect2.y=390;
            addChild(_myRect2);

            _myRect3=new myRect3  ;
            _myRect3.x=sw/2+20;
            _myRect3.y=390;
            addChild(_myRect3);

            _myHane1=new myHane  ;
            _myHane1.y=-15;
            _myCircle2.addChild(_myHane1);

            _myHane2=new myHane  ;
            _myHane2.x=15;
            _myHane2.rotation=90;
            _myCircle2.addChild(_myHane2);

            _myHane3=new myHane  ;
            _myHane3.y=15;
            _myHane3.rotation=180;
            _myCircle2.addChild(_myHane3);

            _myHane4=new myHane  ;
            _myHane4.x=-15;
            _myHane4.rotation=-90;
            _myCircle2.addChild(_myHane4);

            _myRect2.addEventListener(MouseEvent.MOUSE_DOWN,xON);
            _myRect3.addEventListener(MouseEvent.MOUSE_DOWN,xOFF);
            _myCircle2.addEventListener(Event.ENTER_FRAME,xEnter);

        }
        public function xON(e:MouseEvent):void {
            _myFlag=true;
        }
        public function xOFF(e:MouseEvent):void {
            _myFlag=false;
        }
        public function xEnter(e:Event):void {
            if (_myFlag) {
                if (_myRot<30) {
                    _myRot+=0.5;
                } else {
                    _myRot=30;
                }
            }
            if (! _myFlag) {
                if (_myRot>0) {
                    _myRot-=0.5;
                } else {
                    _myRot=0;
                }
            }
            _myCircle2.rotation+=_myRot;
        }
    }
}

import flash.display.Sprite;
class myCircle1 extends Sprite {
    public function myCircle1() {
        this.graphics.lineStyle(1,0x000000,1,false,"none");
        this.graphics.beginFill(0xCCCCCC,1);
        this.graphics.drawCircle(0,0,90);
        this.graphics.endFill();
    }
}
class myCircle2 extends Sprite {
    public function myCircle2() {
        this.graphics.lineStyle(1,0x000000,1,false,"none");
        this.graphics.beginFill(0xCCCCCC,1);
        this.graphics.drawCircle(0,0,15);
        this.graphics.endFill();
    }
}
class myCircle3 extends Sprite {
    public function myCircle3() {
        this.graphics.lineStyle(1,0x000000,1,false,"none");
        this.graphics.beginFill(0xCCCCCC,1);
        this.graphics.drawEllipse(0,0,150,50);
        this.graphics.endFill();
    }
}
class myRect1 extends Sprite {
    public function myRect1() {
        this.graphics.lineStyle(1,0x000000,1,false,"none");
        this.graphics.beginFill(0xCCCCCC,1);
        this.graphics.drawRect(0,0,15,180);
        this.graphics.endFill();
    }
}
class myRect2 extends Sprite {
    public function myRect2() {
        this.graphics.lineStyle(1,0x000000,1,false,"none");
        this.graphics.beginFill(0x0000FF,1);
        this.graphics.drawRect(0,0,15,15);
        this.graphics.endFill();
    }
}
class myRect3 extends Sprite {
    public function myRect3() {
        this.graphics.lineStyle(1,0x000000,1,false,"none");
        this.graphics.beginFill(0xFF0000,1);
        this.graphics.drawRect(0,0,15,15);
        this.graphics.endFill();
    }
}
class myHane extends Sprite {
    public function myHane() {
        this.graphics.lineStyle(1,0x000000,1,false,"none");
        this.graphics.beginFill(0xFFFFFF,1);
        this.graphics.drawEllipse(0,0,87,30);
        this.graphics.endFill();
    }
}