In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

マウスオーバーで四角形回転

マウスを動かすと四角形が回転します。
しばらくすると止まります。
Get Adobe Flash player
by yuugurenote 18 Jun 2012
    Embed
/**
 * Copyright yuugurenote ( http://wonderfl.net/user/yuugurenote )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/jr2p
 */

package {
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.events.Event;
    [SWF(width=465,height=465,backgroundColor=0xFFFFFF,frameRate=60)]
    public class AS120618_01 extends Sprite {
        public var sw:Number=stage.stageWidth;
        public var sh:Number=stage.stageHeight;
        public var _myRect:myRect;
        public var _mySprite:mySprite;
        public var _myArray:Array = new Array();
        public var max:Number=100;

        public function AS120618_01() {

            for (var i:Number=0; i<max; i++) {

                _mySprite = new mySprite();
                _mySprite.x=i%10*46.5 + 23.25;
                _mySprite.y=Math.floor(i/10)*46.5 + 23.25;
                addChild(_mySprite);

                _myRect= new myRect();
                _mySprite.addChild(_myRect);
                _myRect.x=-23.25;
                _myRect.y=-23.25;
                _mySprite.addChild(_myRect);
                _myArray.push(_mySprite);
            
            }
            addEventListener(Event.ENTER_FRAME,xEnter);
        }
        public function xEnter(e:Event):void {
            for (var i:Number=0; i<max; i++) {
                _myArray[i].myAct();
            }
        }
    }
}


import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.events.Event;
class myRect extends Sprite {
    public var myInt:Number=0;
    public var myFlag:Boolean=false;
    public function myRect() {
        this.graphics.beginFill(Math.random()*0xFFFFFF,1);
        this.graphics.drawRect(0,0,46.5,46.5);
        this.graphics.endFill();
    }
}

class mySprite extends Sprite {
    public var myInt:Number=0;
    public var myFlag:Boolean=false;
    public function mySprite() {
    }
    public function myAct():void {
        this.addEventListener(MouseEvent.MOUSE_OVER,xOver);
    }
    public function xOver(e:MouseEvent):void {
        myFlag=true;
        this.addEventListener(Event.ENTER_FRAME,xEnter2);
    }
    public function xEnter2(e:Event):void {
        if (myFlag) {
            myInt+=0.05;
            if (myInt>=10) {
                myFlag=false;
            }
        }
        if ((!myFlag) && (myInt > 0)) {
            myInt-=0.05;
            if (myInt<0.9){
                this.rotation =0;
                //this.removeEventListener(Event.ENTER_FRAME,xEnter2);
            }
        }
        this.rotation+=myInt;
    }
}