forked from: Walker
// forked from miyaoka's Walker
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.filters.*;
[SWF(width = "465", height = "465", backgroundColor = 0xFFFFFF, frameRate = "60")]
public class Main extends Sprite {
private var walkers:Array = new Array();
public function Main():void {
//bg
graphics.beginFill(0x999999);
graphics.drawRect(0, 180, 465, 300);
for(var i:uint = 0;i < 5;i++){
walkers[i] = new Walker();
walkers[i].x = i*50;
walkers[i].y = i*-30;
walkers[i].alpha = 1-i*0.01;
walkers[i].delay = 6-i*1.5+1;
var blur:BlurFilter = new BlurFilter();
blur.blurX = i*2;
blur.blurY = i*2;
walkers[i].filters = [blur];
}
for(var i:uint = 4;i > 0;i--){
addChild(walkers[i])
}
Wonderfl.capture(stage);
}
}
}
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Point;
import flash.events.TimerEvent;
import flash.utils.Timer;
import caurina.transitions.Tweener;
class Walker extends Sprite {
private var rad:Number;
private var r:Number = 0;
private const PI2:Number = Math.PI * 2;
private var speed:Number = 0.05;
private var rAdd:Number = Math.PI * speed;
private var legs:Sprite = new Sprite();
private var body:Sprite = new Sprite();
public var delay:uint = 0;
public function Walker():void {
//body
body.graphics.beginFill(0)//x666666);
body.graphics.drawRoundRect(-40, 0, 80, 60, 60, 60);
body.graphics.beginFill(0xffffff);
body.graphics.drawCircle( -20, 20, 4);
body.graphics.drawCircle( 20, 20, 4);
//legs
var legNum:uint = 4;
for (var i:uint = 0; i < legNum; i ++)
{
var leg:Leg = new Leg();
leg.r = PI2 * (i *1.5) / legNum;
leg.length = 100;
leg.rMul = Math.random() + 0.2;
legs.addChild(leg);
}
//add
addChild(body);
addChild(legs);
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
//
enterFrameHandler(null);
}
private function enterFrameHandler(e:Event):void {
var d:Number = (mouseX - legs.x) * (delay*0.1);
legs.x += d;
body.x = legs.x;
r = (r + d * 0.02 ) % PI2;
legs.graphics.clear();
var heights:Array = new Array();
for (var i:uint; i < legs.numChildren; i++)
{
var leg:Leg = legs.getChildAt(i) as Leg;
var pt:Point = Point.polar(leg.length/2, Math.abs(Math.sin(r + leg.r)) * (i %2 ==0 ? -1 : 1) *1.0 + Math.PI / 2);
var lx:Number = (Math.ceil(i/2)) * 60 / legs.numChildren * ((i % 2 == 0) ? 1 : -1)
+ ((legs.numChildren % 2 == 0) ? 30/ legs.numChildren : 0);
legs.graphics.moveTo(lx, 0);
legs.graphics.lineStyle(16, 0);
legs.graphics.lineTo(lx + pt.x, pt.y);
legs.graphics.lineTo(lx, pt.y*2);
heights.push(pt.y*2)
}
heights.sort(Array.NUMERIC | Array.DESCENDING);
legs.y = 300 - heights[0];
body.y = legs.y - body.height *0.75;
}
}
class Leg
extends Sprite
{
public var r:Number;
public var length:Number;
public var rMul:Number;
public function Leg():void
{
}
}