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

ひも理論 forked from: 多重連結バネ

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

package  {
    import net.hires.debug.Stats;
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.display.Graphics;
    import flash.events.Event;
    [SWF(width = "465", height = "465", backgroundColor = "0xFFFFFF", frameRate = "60")]
    public class Main extends MovieClip {
        private var canvas:MovieClip;
        private var scx:Number;
        private var scy:Number;
        public function Main() {
            var i:uint;
            var stats:Stats=new Stats();
            addChild( stats );
            canvas=new MovieClip();
            addChild(canvas)
            // constructor code
            scx = stage.stageWidth*.5;
            scy = stage.stageHeight*.5;
            //
            canvas.x = scx;
            canvas.y = scy;
            /*
            var mp:MousePoint=new MousePoint();
            addChild(mp);
            */
            for(i=0;i<24;i++){
                var himo:Himo=new Himo();
                himo.x = 150*Math.cos(2*Math.PI*i/24);
                himo.y = 150*Math.sin(2*Math.PI*i/24);
                canvas.addChild(himo);
            }
            
            //canvas.scaleX=0.3
            //canvas.scaleY=canvas.scaleX
            //var g:Graphics=maru.graphics;
            //addEventListener(Event.ENTER_FRAME,ent);
        }
        private function ent(event:Event):void{
            //cnt+=0.01;
            //canvas.scaleX=0.6+0.4*Math.cos(cnt);
            //canvas.scaleY=canvas.scaleX;
            //canvas.rotation ダメ絶対!!
            /*
            var d:Number=Math.sqrt(Math.pow(mouseX-scx,2)+Math.pow(mouseY-scy,2))
            var lastScale:Number=1-0.01*Math.abs(d);
            if(lastScale<0){
                lastScale=0;
            }
            var ds:Number=lastScale-canvas.scaleX;
            canvas.scaleX+=ds*0.02;
            canvas.scaleY=canvas.scaleX
            */
        }
        //
    }
}

import flash.display.MovieClip;
import flash.events.Event;
class Himo extends MovieClip{
    private var mi_ar:Array;
    private var spx:Number;
    private var spy:Number;
    private var color:Number
    public function Himo(){
        var h:Number=20;
        var i:uint=0;
        mi_ar=new Array();
        var lx:Number=mouseX;
        var ly:Number=mouseY;
        var pin:Pin=new Pin();
        pin.x=0;
        pin.y=0;
        addChild(pin)
        mi_ar.push(pin);
        var p:MovieClip
        for(i=1;i<h;i++){
            p=new Mi();
            addChild(p);
            p.x= lx *i/h
            p.y= ly *i/h
            mi_ar.push(p)
        }
        var mp:MousePoint=new MousePoint();
        addChild(mp);
        mi_ar.push(mp);
        //
        for(i=1;i<mi_ar.length-1;i++){
            p=mi_ar[i];
            p.init([mi_ar[i-1],mi_ar[i+1]])
        }
        //
        addEventListener(Event.ENTER_FRAME,ent)
        //
    }
    private function ent(evt:Event):void{
        var i:uint;
        var g:Graphics=this.graphics;
        g.clear()
        g.lineStyle(1,0xFF0000);
        g.moveTo(mi_ar[i].x,mi_ar[i].y);
        for(i=1;i<mi_ar.length;i++){
            g.lineTo(mi_ar[i].x,mi_ar[i].y);
        }
    }
    //
}


import flash.display.Graphics;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Point;

class Mi extends MovieClip {
    private var m:Number=1
    private var k:Number=0.08;
    private var t:Number=0.1;
    private var g:Number=0.3*0.98;
    private var m_ar:Array
    
    private var ax:Number;
    private var ay:Number;
    private var vx:Number;
    private var vy:Number;
    private var px:Number;
    private var py:Number;
    public function Mi() {

    }
    public function init(_ar:Array):void{
        m_ar=_ar;
        ax=0;
        vx=0;
        ay=0;
        vy=0;
        px=m_ar[0].x;
        py=m_ar[0].y;
        addEventListener(Event.ENTER_FRAME,ent);
    }
    //
    private function ent(evt:Event):void{
        
        var i:uint
        var dx:Number=0;
        var dy:Number=0;
        var thisPoint:Point=new Point(this.x,this.y)
        //var thisGoint:Point=globalToLocal(thisPoint)
        var thisGoint:Point=localToGlobal(thisPoint)

        for(i=0;i<m_ar.length;i++){
            var mc:MovieClip=m_ar[i];
            var mcPoint:Point=new Point(mc.x,mc.y);
            //var mcGoint:Point=globalToLocal(mcPoint);
            var mcGoint:Point=localToGlobal(mcPoint);
            dx+=mcGoint.x-thisGoint.x;
            dy+=mcGoint.y-thisGoint.y;
        }
        ax=k*dx//
        ay=k*dy+g//
        vx+=ax-t*vx;
        vy+=ay-t*vy;
        this.x+=vx;
        this.y+=vy;
    }
}

import flash.display.MovieClip;
import flash.display.Graphics;
class Pin extends MovieClip {
    public function Pin() {
        // constructor code
        var g:Graphics=this.graphics;
        g.beginFill(0x000000);
        g.drawCircle(0,0,2);
    }
}

class MousePoint extends Pin {
    public function MousePoint() {
        addEventListener(Event.ENTER_FRAME,ent);
    }
    //
    private function ent(evt:Event):void{
        this.x = MovieClip(this.parent).mouseX;
        this.y = MovieClip(this.parent).mouseY;
    }
}