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

ソナーっぽいもの

ラインが触れる前に目標物が反応してしまいます。
hitTestObjectで判定しているのですが
いつかもっと綺麗に反応するコードにしたいです。
Get Adobe Flash player
by yuugurenote 03 Nov 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/aZaM
 */

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

    public class AS111103_02 extends Sprite {
        public var sw:Number=stage.stageWidth;
        public var sh:Number=stage.stageHeight;
        public var _mySprite:mySprite;
        public var _myCircle:myCircle;
        public var _myLine:myLine;
        public var _myObj:myObj;
        public var _myObjArr:Array = new Array();
        public var max:Number=10;

        public function AS111103_02() {

            _mySprite = new mySprite();
            _mySprite.x=sw/2;
            _mySprite.y=sh/2;
            addChild(_mySprite);

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

            _myLine = new myLine();
            _myLine.x=sw/2;
            _myLine.y=sh/2;
            addChild(_myLine);

            for (var i:int = 0; i < max; i++) {
                _myObj= new myObj();
                _myObj.x=Math.random()*380+25;
                _myObj.y=Math.random()*380+25;
                _myObj.alpha=0;
                addChild(_myObj);
                _myObjArr.push(_myObj);
            }
            addEventListener(Event.ENTER_FRAME, xEnter4);

        }
        private function xEnter4(e:Event):void {
            for (var i:int = 0; i < max; i++) {
                if (_myObjArr[i].hitTestObject(_mySprite)) {
                    _myObjArr[i].alpha+=0.05;
                } else {
                    _myObjArr[i].alpha=0;
                }
            }
        }

    }
}

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

class mySprite extends Sprite {

    public function mySprite() {

        this.graphics.lineStyle(3,0x00FF00,1,false,"none");
        this.graphics.moveTo(0,0);
        this.graphics.lineTo(0,230);
        this.addEventListener(Event.ENTER_FRAME,xEnter2);

    }

    public function xEnter2(e:Event):void {
        this.rotation+=1;
    }
}

class myCircle extends Sprite {
    public function myCircle() {
        this.graphics.lineStyle(5,0x00FF00,1,false,"none");
        this.graphics.drawCircle(0,0,230);
    }
}

class myLine extends Sprite {
    public function myLine() {
        this.graphics.lineStyle(0.5,0x00FF00,1,false,"none");
        this.graphics.moveTo(0,0);
        this.graphics.lineTo(230,0);
        this.graphics.moveTo(0,0);
        this.graphics.lineTo(0,230);
        this.graphics.moveTo(0,0);
        this.graphics.lineTo(-230,0);
        this.graphics.moveTo(0,0);
        this.graphics.lineTo(0,-230);
    }
}

class myObj extends Sprite {
    public var myFlag:Boolean=false;

    public function myObj() {
        this.graphics.beginFill(0x00FF00,1);
        this.graphics.drawCircle(0,0,3);
        this.graphics.endFill();
    }
}