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

Limaçon on 2017-2-9

Get Adobe Flash player
by J.J 09 Feb 2017
    Embed
/**
 * Copyright J.J ( http://wonderfl.net/user/J.J )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/4uK3
 */

package  {

    

    import flash.display.MovieClip;

    import flash.events.Event;

    import flash.display.Graphics;

    import flash.geom.Point;

    import flash.events.MouseEvent;

    import flash.text.TextField;

    import flash.display.Sprite;

    import com.bit101.components.Label;

    import com.bit101.components.PushButton;

    import com.bit101.components.HSlider;

    import com.bit101.components.Component;

    import com.bit101.components.CheckBox;

    import flash.geom.ColorTransform;

    import com.bit101.components.Slider;

    




    

    [SWF(backgroundColor=0xffffff, width=480, height=480, frameRate=60)]

    public class Pedal extends MovieClip {

        //taylor series



        public var g:Graphics;

        public var h:int;

        public var w:int;

        public var m:Point;

        public var mo:Point;

        public var cm:Point;

        public var sf:Number=6;

        public var points:Array=[];

        public var O:Point;

        public var isDown:Boolean=false;

        public var ObjClicked:Boolean=false;

        public var Htxs:Vector.<Label>;

        public var Vtxs:Vector.<Label>;

        public var a:Object;

        public var c:Object

        public var clickables:Array=[];

        public var q:Object

        public var theta:Number=0;

    

        public var slider:Slider;

        public function Pedal() {

            

            

            Htxs=new Vector.<Label>();

            Vtxs=new Vector.<Label>();

            g=this.graphics;

            h=stage.stageHeight;

            w=stage.stageWidth;

            m=new Point();

            mo=new Point();

            cm=new Point();

            O=new Point(w/2,h/2);

            var mc:Sprite=new Sprite();

                

                    var qc:Sprite=new Sprite();

                    qc.graphics.beginFill(0x101010);

                qc.graphics.drawRect(0,0,w,h);

                    qc.addChild(mc);

                    this.addChild(qc)

                var step:Number=10;

                var st:Number = 0;

            var gc:Graphics=qc.graphics;

            gc.lineStyle(1,0xffffff,.1)

            

                    

            for(var i:int;i<6;i++){

                var tx:Label=new Label(this);

                

                tx.text="0";

                 

                

                tx.x=i*(w/6);

                tx.y=O.y;

                Htxs.push(tx);

                }

                

                for(i=0;i<6;i++){

                tx=new Label(this);

                tx.y=i*(w/6);

                tx.x=O.x;

                Vtxs.push(tx);

                }

                

                a={x:0,y:-2*w/6,isClicked:false,update:null};;

                c={x:0,y:-1*w/6,isClicked:false,update:null};

                

            

                

                    

                    c.update=a.update=function (o:Object){

                    

                    o.y=stage.mouseY-O.y;

                    o.x=stage.mouseX-O.x;

                    }

                    

                    c.update=function (o:Object){

                    

                    o.y=stage.mouseY-O.y;

                    

                    }

                clickables.push(a);

                clickables.push(c);

                

                

                

                g=mc.graphics;

                

                    slider=new Slider(Slider.HORIZONTAL,this,10,10);

                    slider.value=25

                    

                    var l:Label=new Label(this,10,20,"speed");

                    var l2:Label=new Label(this,10,40,"Move red and white points")

                //    slider.name="slider"

                    //slider.metaData="fff"

                    //animated.selected=true;

            qc.addEventListener(MouseEvent.MOUSE_DOWN,onMD);

            qc.addEventListener(MouseEvent.MOUSE_UP,onMU);

            

            

            this.addEventListener(Event.ENTER_FRAME,loop);

             

        }

    

        public function onMD(e:MouseEvent){

            

            

                isDown=true;

            m.setTo(stage.mouseX,stage.mouseY);

            

            }

        public function onMU(e:MouseEvent){

                isDown=false;

            ObjClicked=false;

            for each(var o:Object in clickables){o.isClicked=false;}

            O=O.add(mo);

            mo.setTo(0,0);

            }

        

    public function loop(e:Event):void{

        g.clear();

        

        if(isDown && ObjClicked==false){

            cm.setTo(stage.mouseX,stage.mouseY);

            mo.setTo(cm.x-m.x,cm.y-m.y);

            O=O.add(mo);

            g.moveTo(m.x,m.y);

            g.lineTo(cm.x,cm.y);

             

            }

        

        

        draw();

            for(var i:int;i<6;i++){

                var tx:Label=Htxs[i];

                tx.y=O.y;

                tx.y=Math.max(tx.y,0);

                tx.y=Math.min(tx.y,h-15)

            var xt:Number = (i / 6) *sf-(O.x/w)*sf;

                        tx.text=xt.toFixed(2)+"";

                var tx2:Label=Vtxs[i];

                tx2.x=O.x;

                tx2.x=Math.max(tx2.x,0)

                tx2.x=Math.min(tx2.x,w-15)

                xt = (i / 6) *sf-(O.y/h)*sf;

                xt*=-1;

            tx2.text=xt.toFixed(2)+"";

                        

            }

        

            

            drawLim();

            O=O.subtract(mo);

            

            

    }

    

    public function drawLim(){

    //    trace(slider.value)

        theta+=.02*Math.PI*(slider.value/100)

        var rad:Number=c.y;

        g.drawCircle(O.x,O.y,rad)

        var si:Number=Math.sin(theta);

        var co:Number=Math.cos(theta);

        var p={x:co*rad,y:si*rad}

        g.lineStyle(0,0,0)

        g.beginFill(0xff0000,1);

        g.drawCircle(p.x+O.x,p.y+O.y,3);

        g.endFill()

        g.lineStyle(1,0xffffff,1)

    g.moveTo(O.x+p.x+si*-500,O.y+p.y-co*-500)

    g.lineTo(O.x+p.x+si*500,O.y+p.y-co*500);

        

        

    

        var aDotn=a.x*si+a.y*-co;

        

    g.drawCircle(O.x+p.x+si*aDotn,O.y+p.y-co*aDotn,2);

        var dir:Point=new Point(p.x+si*aDotn-a.x,p.y-co*aDotn-a.y);

        g.lineStyle(1,0x00f6ff)

        g.moveTo(O.x+a.x+dir.x*-500,O.y+a.y+dir.y*-500)

        g.lineTo(O.x+a.x+dir.x*500,O.y+a.y+dir.y*500)

    

        points.push(new Point(p.x+si*aDotn,p.y-co*aDotn))

        if(points.length>400) points.shift()

        

        g.lineStyle(3,0xff0000);

        g.moveTo(O.x+points[0].x,O.y+points[0].y)

        for (var i:int;i<points.length;i++){

            var ii:Number=(i/points.length)

            var po:Point=points[i]

            g.lineStyle(3,0xff0000,ii);

            g.lineTo(O.x+po.x,O.y+po.y)

        }

        g.lineStyle(0,0,0)

        

        g.beginFill(0xff5a00,1)

        g.drawCircle(a.x+O.x,a.y+O.y,5)

        g.beginFill(0xfffffff);

        g.drawCircle(c.x+O.x,c.y+O.y,5)

        if(isDown){

        for each(var o:Object in clickables){

    

            var m=new Point(o.x+O.x-stage.mouseX,o.y+O.y-stage.mouseY)

            var d:Number=m.x*m.x+m.y*m.y;

            if(o.isClicked==true && o.update!=null) o.update(o);

            if(d<25) {

                

                    

                if(ObjClicked==false){

                    ObjClicked=true;

                o.isClicked=true;

                    }

            

                }

            }

        }

        

        }

    

    

    public function draw(){

    g.lineStyle(1,0xffffff);

        g.moveTo(0, O.y);

        g.lineTo(w, O.y);

        g.moveTo(O.x, 0);

        g.lineTo(O.x, h);



            

            

        }

    

    

    }

    

    

}