flash on 2009-6-24

by set0
♥2 | Line 71 | Modified 2009-06-24 22:46:53 | MIT License
play

ActionScript3 source code

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

package 
{
    import flash.display.*;
    import flash.events.*;
   
    [SWF(width=465, height=465, frameRate=60, backgroundColor=0x000000)]
    public class FlashTest3d00 extends Sprite
    {
        private var sp_list:Array = [];
		private var center_x:Number = stage.stageWidth / 2;
        private var center_y:Number = stage.stageHeight / 2;
       
        public function FlashTest3d00()
        {
            Wonderfl.capture_delay(5);
			addEventListener(Event.ENTER_FRAME, onEnterFrame);
        }
       
        private function onEnterFrame(e:Event):void
        {
			sp_list.push(new Plus(center_x, center_y));
			var max:int = sp_list.length;
			addChild(sp_list[max - 1]);
			
            for (var i:int = 0; i < max; i++) {
                if (sp_list[i].move(stage.mouseX, stage.mouseY) == false) {
					removeChild(sp_list[i]);
					sp_list.splice(i, 1);
					i--;
					max--;
					continue;
                }
            }
        }
    }
}

import flash.display.*;

class Plus extends Sprite
{
    public var _z:Number = 1000;
    public var init_x:Number;
    public var init_y:Number;
    public var center_x:Number;
    public var center_y:Number;
    public var fl:Number = 100;
   
    public function Plus(x:Number, y:Number)
    {
        this.x = -100;
        this.y = -100;
        this.init_x = Math.random() * 500 - 250;
        this.init_y = Math.random() * 500 - 250;
        this.center_x = x;
        this.center_y = y;
               
        graphics.lineStyle(8, 0xff9900 , 1, false, "normal", CapsStyle.SQUARE);
		graphics.moveTo(10, 0);
		graphics.lineTo(10, 20);
		graphics.moveTo(0, 10);
		graphics.lineTo(20, 10);
    }
   
    public function move(x:Number, y:Number):Boolean
    {
        this._z -= 10;
       
        if (this._z < 0 ) {
            return false;
        }
       
        var scale:Number = this.fl / (this.fl + this._z);
       
		this.init_x += (this.center_x - x) / 5;
		this.init_y += (this.center_y - y) / 5;
		
        this.x = this.init_x * scale + this.center_x;
        this.y = this.init_y * scale + this.center_y;
       
        this.scaleX = scale;
        this.scaleY = scale;
       
        return true;       
    }
}