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 23 Aug 2011
    Embed
/**
 * Copyright yuugurenote ( http://wonderfl.net/user/yuugurenote )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/psnS
 */

package {
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.events.Event;
    [SWF(width=465,height=465,backgroundColor=0xFFFFFF,frameRate=60)]

    public class AS110823_01 extends Sprite {
        public var sw:Number=stage.stageWidth;
        public var sh:Number=stage.stageHeight;
        public var _myCircle:myCircle;
        public var _mySprite:mySprite;
        public var mySprite_Ar:Array=new Array  ;
        public var mySpeedX:Array=new Array(0,1.5,1.5,1.5,0,-1.5,-1.5,-1.5);
        public var mySpeedY:Array=new Array(-1.5,-1.5,0,1.5,1.5,1.5,0,-1.5);
        public var SpeedX:Number = 1.5;
        public var SpeedY:Number = 0;
        
        public function AS110823_01() {

            _myCircle=new myCircle  ;
            _myCircle.x=sw/2;
            _myCircle.y=sh/2;
            addChild(_myCircle);

            for (var i:Number=0; i<8; i++) {
                _mySprite=new mySprite  ;
                _mySprite.x=i*50+50;
                _mySprite.y=50;
                _mySprite.rotation=i*45;
                addChild(_mySprite);
                mySprite_Ar.push(_mySprite);
            }

            addEventListener(Event.ENTER_FRAME,xChk);

        }

        public function xChk(e:Event):void {

                    _myCircle.x+=SpeedX;
                    _myCircle.y+=SpeedY;
                for (var i:Number=0; i<mySprite_Ar.length; i++) {
                if (_myCircle.hitTestObject(mySprite_Ar[i])) {
                    SpeedX=mySpeedX[i];
                    SpeedY=mySpeedY[i];
                }
                }
        }


    }
}

import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.events.Event;

class myCircle extends Sprite {

    public function myCircle():void {

        graphics.beginFill(0xCCCCCC,1);
        graphics.drawCircle(0,0,10);
        graphics.endFill();

        addEventListener(Event.ENTER_FRAME,xEnter);

    }
    public function xEnter(e:Event):void {
        if (this.x>stage.stageWidth)     this.x=0;
        if (this.y > stage.stageHeight) this.y = 0;
        if (this.x < 0) this.x = stage.stageWidth;
        if (this.y < 0) this.y = stage.stageHeight;
    }

}

class mySprite extends Sprite {
    private var myFlag:Boolean=false;
    public function mySprite():void {

        graphics.lineStyle(1,0x000000,1);
        graphics.beginFill(0xCCCCCC,1);
        graphics.moveTo(0,0);
        graphics.lineTo(7.5,13);
        graphics.lineTo(3,13);
        graphics.lineTo(3,28);
        graphics.lineTo(-3,28);
        graphics.lineTo(-3,13);
        graphics.lineTo(-7.5,13);
        graphics.lineTo(0,0);
        graphics.endFill();

        addEventListener(MouseEvent.MOUSE_DOWN,s_Drag);
        addEventListener(MouseEvent.MOUSE_UP,e_Drag);
        addEventListener(MouseEvent.MOUSE_MOVE,e_Update);
        buttonMode=true;
    }
    private function e_Update(e:MouseEvent):void {
        if (myFlag) {
            e.updateAfterEvent();
        }
    }
    private function s_Drag(e:MouseEvent):void {
        myFlag=true;
        this.startDrag();
    }
    private function e_Drag(e:MouseEvent):void {
        myFlag=false;
        this.stopDrag();
    }
}