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

block7

Get Adobe Flash player
by Maeda_addevent 29 Jul 2012
    Embed
/**
 * Copyright Maeda_addevent ( http://wonderfl.net/user/Maeda_addevent )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/rpJX
 */

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

    public class FB00011 extends Sprite {
        public var sw:Number=stage.stageWidth;
        public var sh:Number=stage.stageHeight;
        public var r:Number = 15;
        public var _mySprite:mySprite;
        public var _myArray:Array;
        public var num:uint = 0;
        public var _myFlag:Boolean = false;

        public function FB00011() {
            _myArray = new Array();
            stage.addEventListener(MouseEvent.MOUSE_DOWN,xDown);
            stage.addEventListener(Event.ENTER_FRAME,xEnter);
        }
        private function xDown(e:MouseEvent):void {
            _mySprite = new mySprite(r);
            _mySprite.x = mouseX;
            _mySprite.y = -10;
            addChild(_mySprite);
            _myArray.push(_mySprite);
        }
        private function xEnter(e:Event):void {
            action_move();
            action_chk();
        }
        private function action_move():void {
            for each (var _mySprite:mySprite in _myArray) {
                _mySprite.Move();
            }
        }
        private function action_chk():void {
            for (var i:uint = 0; i < _myArray.length; ++i) {
                for (var j:uint = 0; j < i; ++j) {
                    if (i==j) {
                        continue;
                    }
                    _myArray[i].Chk(_myArray[j]);
                }
            }
        }
    }
}

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

class mySprite extends Sprite {
    
    public var color:Number = Math.random() * 0xFFFFFF;
    public var _width:Number;
    public var _height:Number;
    public var _flag:Boolean;
    public var speed:Number;

    public function get flag():Boolean {    return _flag;}
    public function get left():Number {    return this.x - (_width * 0.5);}
    public function get right():Number {return this.x + (_width * 0.5);}    
    public function get top():Number {    return this.y - _height/2;}
    public function get bottom():Number {return this.y;}
    
    public function mySprite(r:Number) {
        var g=this.graphics;
        g.lineStyle(0.5,0x000000,0,false,"none");
        g.beginFill(color,0.6);
        g.moveTo(0,0);
        g.lineTo(r*0.865,r/2);
        g.lineTo(0,r);
        g.lineTo(-r*0.865,r/2);
        g.lineTo(0,0);
        g.endFill();
        
        g.lineStyle(0.5,0x000000,0,false,"none");
        g.beginFill(color,1);
        g.moveTo(-r*0.865,r/2);
        g.lineTo(0,r);
        g.lineTo(0,r*2);
        g.lineTo(-r*0.865,r*1.505);
        g.lineTo(-r*0.865,r/2);
        g.endFill();

        g.lineStyle(0.5,0x000000,0,false,"none");
        g.beginFill(color,0.8);
        g.moveTo(0,r);
        g.lineTo(r*0.865,r/2);
        g.lineTo(r*0.865,r*1.505);
        g.lineTo(0,r*2);
        g.lineTo(0,r);
        g.endFill();
        
        _width = this.width;
        _height = this.height;
        speed = 0;
        _flag = false;
    }
    public function Move():void {
        if(_flag) { return; }
        speed += 0.2;
        if (speed > 8) { speed =8; }
        this.y += speed;
        if (this.y > stage.stageHeight - _height) {
            this.y = stage.stageHeight - _height;
            finish();
        }
    }
    public function Chk(_mySprite:mySprite):void {
        if (! this.flag) {
            if (Chk2(_mySprite)) {
                this.y=_mySprite.top;
                finish();
            }
        }
    }
    private function Chk2(_mySprite:mySprite):Boolean {
        if (! _mySprite.flag) {
            return false;
        }
        if (this.bottom>=_mySprite.bottom) {
            return false;
        }

        if ((this.left >= _mySprite.left && this.left <= _mySprite.right)
                || (this.right >= _mySprite.left && this.right <= _mySprite.right)
                || (_mySprite.left >= this.left && _mySprite.left <= this.right)
                || (_mySprite.right >= this.left && _mySprite.right <= this.right)
                ) 
        {
            if (this.bottom<=_mySprite.bottom&&this.bottom>=_mySprite.top) {
                return true;
            }
        }

        return false;
    }
    private function finish():void {
        speed=0;
        _flag = true;
    }
}