forked from: flash on 2009-6-24

by set0 forked from flash on 2009-6-24 (diff: 62)
♥2 | Line 98 | Modified 2009-06-25 15:32:51 | 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/jQIo
 */

package 
{
    import flash.display.*;
    import flash.events.*;
	import flash.geom.*;
   
    [SWF(width=465, height=465, frameRate=60, backgroundColor=0x000000)]
    public class FlashTest3d04 extends Sprite
    {
        private var sp_list:Array = [];
		private var center_x:Number = stage.stageWidth / 2;
        private var center_y:Number = stage.stageHeight / 2;
		private var flag:Boolean = true;
		private var buffer:BitmapData = new BitmapData(465, 465, false, 0x000000);
		private var screen:Bitmap = new Bitmap(buffer);
		private var shape_size:Number = 40;
		private var line_size:Number = 10;
       
        public function FlashTest3d04()
        {
             Wonderfl.capture_delay( 10 );
			addChild(screen);
			addEventListener(Event.ENTER_FRAME, onEnterFrame);
        }
       
        private function onEnterFrame(e:Event):void
        {
			sp_list.push(new Plus(center_x, center_y, flag));
			flag = !flag;
			
			var max:int = sp_list.length;
			var shape:Shape = new Shape();
			var tmp_line_size:Number;
			var tmp_shape_size:Number;

            for (var i:int = 0; i < max; i++) {
                if (sp_list[i].move(stage.mouseX, stage.mouseY) == false) {
					sp_list.splice(i, 1);
					i--;
					max--;
					continue;
                }
            }
			
			sp_list.sortOn("z", Array.DESCENDING | Array.NUMERIC);
			
			for (i = 0; i < max; i++) {
				
				tmp_line_size = line_size * sp_list[i].scale;
				tmp_shape_size = shape_size * sp_list[i].scale;
				
				if (tmp_line_size < 0.01 || tmp_shape_size < 0.01) {
					continue;
				}
				
				shape.graphics.lineStyle(tmp_line_size, sp_list[i].color , 1, false, "normal", CapsStyle.SQUARE);
				shape.graphics.moveTo(sp_list[i].x + tmp_shape_size / 2, sp_list[i].y);
				shape.graphics.lineTo(sp_list[i].x + tmp_shape_size / 2, sp_list[i].y + tmp_shape_size);
				shape.graphics.moveTo(sp_list[i].x, sp_list[i].y + tmp_shape_size / 2);
				shape.graphics.lineTo(sp_list[i].x + tmp_shape_size, sp_list[i].y + tmp_shape_size / 2);
			}
			
			buffer.colorTransform(buffer.rect, new ColorTransform(0, 0, 0, 0, 0, 0, 0, 0));
			buffer.draw(shape);
        }
    }
}

import flash.display.*;

class Plus
{
	public var x:Number = -100;
	public var y:Number = -100;
	public var z:Number = 3000;
	public var init_x:Number = -100;
	public var init_y:Number = -100;
	public var center_x:Number;
	public var center_y:Number;
	public var fl:Number = 100;
	public var flag:int = 0;
	public var scale:Number = 0;
        public var color:uint = 0xffffff * Math.random();
	
	public function Plus(x:Number, y:Number, flag:Boolean) 
	{
    Wonderfl.capture_delay( 10 );
		this.center_x = x;
		this.center_y = y;
		this.flag = int(flag);
	}
	
	public function move(x:Number, y:Number):Boolean
	{
		this.z -= 5;
		
		if (this.z < 0 ) {
			return false;
		}
		
		moveMouse(x, y);
		return true;		
	}
	
	public function moveMouse(x:Number, y:Number):void
	{
		var scale:Number = this.fl / (this.fl + this.z);
		
		this.init_x = Math.cos((this.z + 180 * this.flag) * Math.PI / 180) * 400;
		this.init_y = Math.sin((this.z + 180 * this.flag) * Math.PI / 180) * 400;
		
		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.scale = scale;
	}
}

Forked