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

ぴよザイル

本当は首だけ回したかった…
//////////////////////////////////////////////////////////////////////////////
ぴよザイル
//////////////////////////////////////////////////////////////////////////////
/**
 * Copyright ProjectNya ( http://wonderfl.net/user/ProjectNya )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/rie1
 */

// forked from Nicolas's ピヨザイル
// forked from ProjectNya's 輪になって回るひよこちゃん
//本当は首だけ回したかった…
////////////////////////////////////////////////////////////////////////////////
// ぴよザイル
////////////////////////////////////////////////////////////////////////////////

package {

	import flash.display.Sprite;
	import flash.display.MovieClip;
	import flash.display.Loader;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.net.URLRequest;
	import flash.system.Security;
	import flash.system.LoaderContext;
	import flash.display.Shape;
	import flash.geom.Matrix;
	import flash.display.GradientType;

	[SWF(backgroundColor="#FFFFFF", width="465", height="465", frameRate="30")]

	public class Main extends Sprite {
		private static var basePath:String = "http://assets.wonderfl.net/images/related_images/";
		private static var sunshinePath:String = "9/9b/9bbe/9bbec77d53bddc5e7a5f2c00abbade6bd641c549";
		private var loader:Loader;
		private static var piyoPath:String = "http://www.project-nya.jp/images/flash/piyo2d.swf";
		private var Piyo:Class;
		private var piyo:MovieClip;
		private var angle:Number = 0;
		private static var max:uint = 5;
		private var piyos:Array;
		private var angles:Array;
		private var px:Number;
		private var py:Number;
		private static var radian:Number = Math.PI/180;

		public function Main() {
			//Wonderfl.disable_capture();
			Wonderfl.capture_delay(4);
			init();
		}

		private function init():void {
			draw();
			Security.allowDomain("www.project-nya.jp");
			loader = new Loader();
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete, false, 0, true);
			loader.load(new URLRequest(piyoPath), new LoaderContext(true));
			piyos = new Array();
			angles = new Array();
		}
		private function complete(evt:Event):void {
			loader.removeEventListener(Event.COMPLETE, complete);
			var content:MovieClip = MovieClip(evt.target.content);
			//Piyoクラス
			Piyo = MovieClip(content.piyo).constructor;
			px = MovieClip(content.piyo).head.x;
			py = MovieClip(content.piyo).head.y;
			setup();
			loader = null;
		}
		private function setup():void {
			for (var n:uint = 0; n < max; n++) {
				var piyo:MovieClip = new Piyo();
				addChild(piyo);
				piyo.x = 232;
				piyo.y = 360 + 20*n;
				piyo.scale = 4;
				if (n < max - 1) piyo.shade.visible = false;
				piyos.push(piyo);
				angles.push(360/max*n);
			}
			addEventListener(Event.ENTER_FRAME, update, false, 0, true);
		}
		private function update(evt:Event):void {
			for (var n:uint = 0; n < max; n++) {
				var piyo:MovieClip = piyos[n];
				angles[n] -= 5;
				piyo.head.x = px + 3*(max-n)*Math.cos(angles[n] *radian);
				piyo.head.y = py + 3*(max-n)*Math.sin(angles[n] *radian);
			}
		}
		/////////////////////////////////////////////
		//背景
		/////////////////////////////////////////////
		private function draw():void {
			drawSky();
			drawGround();
			drawSun();
		}
		private function drawSky():void {
			var matrix:Matrix = new Matrix();
			matrix.createGradientBox(465, 350, 0.5*Math.PI, 0, 0);
			graphics.beginGradientFill(GradientType.LINEAR, [0x3F68AB, 0x77B2EE], [1, 1], [0, 255], matrix);
			graphics.drawRect(0, 0, 465, 350);
			graphics.endFill();
		}
		private function drawGround():void {
			var matrix:Matrix = new Matrix();
			matrix.createGradientBox(465, 115, 0.5*Math.PI, 0, 350);
			graphics.beginGradientFill(GradientType.LINEAR, [0x99CC33, 0x7EB133], [1, 1], [0, 255], matrix);
			graphics.drawRect(0, 350, 465, 115);
			graphics.endFill();
		}
		private function drawSun():void {
			var matrix:Matrix = new Matrix();
			matrix.createGradientBox(200, 200, 0, -90, -90);
			graphics.beginGradientFill(GradientType.RADIAL, [0xFFFFFF, 0xFFFFFF, 0xFFFFFF], [1, 0.3, 0], [25, 102, 231], matrix);
			graphics.drawCircle(10, 10, 100);
			graphics.endFill();
			var shine:Loader = new Loader();
			addChild(shine);
			shine.alpha = 0.5;
			shine.load(new URLRequest(basePath + sunshinePath));
		}

	}

}


class Perspective {
	private var objList:Array;
	private var fl:Number = 250;
	private var vp:Object;
	private var view:Object;
	private var ax:Number = 0;
	private var ay:Number = 0;
	private var az:Number = 0;
	private var brighted:Boolean = false;
	private var front:Number = -100;
	private var back:Number = 100;
	private var depthList:Array;

	public function Perspective() {
		objList = new Array();
		vp = {x: 0, y: 0};
		view = {x: 0, y: 0, z: 0};
		depthList = new Array();
	}

	public function init(x:int, y:int):void {
		vp = {x: x, y: -y};
	}
	public function register(obj:Object3D, n:uint):void {
		objList.push(obj);
		obj.id = n;
	}
	public function transform():void {
		for (var n:uint = 0; n < objList.length; n++) {
			var obj:Object3D = objList[n];
			setPerspective(obj);
		}
		manageDepths();
	}
	private function setPerspective(obj:Object3D):void {
		if (obj.pz + view.z > - fl + 50) {
			var scale:Number = fl/(fl + obj.pz + view.z);
			obj.scale = scale;
			obj.x = vp.x + (obj.px - view.x)*scale;
			obj.y = - vp.y - (obj.py + view.y)*scale;
		if (brighted) obj.brightness = -100*(obj.pz + view.z - front)/(back - front);
			obj.visible = true;
		} else {
			obj.visible = false;
		}
	}
	private function manageDepths():void {
		objList.sortOn(["pz", "id"], [Array.DESCENDING | Array.NUMERIC, Array.DESCENDING | Array.NUMERIC]);
		for (var n:uint = 0; n < objList.length; n++) {
			var obj:Object3D = objList[n];
			obj.stage.addChildAt(obj, n+1);
		}
	}
	public function screen(f:Number, b:Number):void {
		if (front == back) {
			brighted = false;
		} else {
			brighted = true;
			front = f;
			back = b;
		}
	}
	public function setView(x:Number, y:Number, z:Number):void {
		view.x = x;
		view.y = -y;
		view.z = -z;
		transform();
	}

}


import flash.display.Sprite;
import flash.geom.ColorTransform;

class Object3D extends Sprite {
	public var id:uint;
	public var px:Number;
	public var py:Number;
	public var pz:Number;
	public var angle:Number;
	private var _scale:Number = 1;
	private var colorTrans:ColorTransform;
	private var _brightness:Number = 0;

	public function Object3D() {
		colorTrans = new ColorTransform(0, 0, 0, 1, 0, 0, 0, 0);
	}

	public function get scale():Number {
		return _scale;
	}
	public function set scale(param:Number):void {
		_scale = param;
		scaleX = scaleY = _scale;
	}
	public function get brightness():Number {
		return _brightness;
	}
	public function set brightness(param:Number):void {
		_brightness = param;
		var percent:uint = 100 - Math.abs(param);
		var offset:uint = (param > 0) ? (255*param*0.01) : 0;
		setColorTrans(percent, offset);
	}
	private function setColorTrans(percent:Number, offset:Number):void {
		colorTrans.redMultiplier = percent*0.01;
		colorTrans.greenMultiplier = percent*0.01;
		colorTrans.blueMultiplier = percent*0.01;
		colorTrans.redOffset = offset;
		colorTrans.greenOffset = offset;
		colorTrans.blueOffset = offset;
		colorTrans.alphaMultiplier = alpha;
		colorTrans.alphaOffset = 0;
		transform.colorTransform = colorTrans;
	}

}