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

flash on 2013-5-19

Get Adobe Flash player
by tepe 21 May 2013
    Embed
/**
 * Copyright tepe ( http://wonderfl.net/user/tepe )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/oXA8
 */

package {
    import flash.display.*;
    import flash.text.*;
    import flash.events.*;
    public class FlashTest extends Sprite {
        private var tf:TextField = new TextField();
        private var s:Sprite = new Sprite();
        private var a:Number = 5;

        private var b:Number = 10;
        private var c:Number = Math.sqrt(a*a+b*b);
        
        private var rad:Number = Math.atan2(a,b);
        private var deg:Number = rad/Math.PI*180;
        private var sin:Number = a/c;
        private var cos:Number = b/c;
        private var tan:Number = a/b;
        private var ac:arc = new arc();
        
        public function FlashTest() {
            scaleY = 1;
            scaleX = 1;
            
            addEventListener(MouseEvent.CLICK,onClick);
            // write as3 code here..
            addChild(tf);
            tf.width = 400;
            tf.height = 400;
            tf.text = "aaa";
            tf.text = "c   ="+c.toString();
            tf.appendText("\nrad = "+rad.toString());
            tf.appendText("\ndeg = "+deg.toString());
            tf.appendText("\nsin = "+sin.toString());
            tf.appendText("\ncos = "+cos.toString());
            tf.appendText("\ntan = "+tan.toString());
            
            addChild(s);
            s.x = 200;
            s.y = 200;
            var r:Number= 100/c;
            s.graphics.lineStyle(1,0xaaaaaa);
            s.graphics.drawCircle(0,0,r*c);
            s.graphics.moveTo(0,-400);
            s.graphics.lineTo(0,400);
            s.graphics.moveTo(-400,0);
            s.graphics.lineTo(400,0);
            s.graphics.lineStyle(1,0x000000);
            s.graphics.moveTo(0,0);
            s.graphics.lineTo(b*r,a*r);//c
            s.graphics.lineTo(r*b,0);//a
            s.graphics.lineTo(0,0);//b
            
            
            ac.draw_arc(200,200,c*r,0,rad,1);
            addChild(ac);
            
        }
        private function onClick(e:MouseEvent):void{
            s.graphics.clear();
            a = Math.round(Math.random()*200-100);
            b = Math.round(Math.random()*200-100);
            c = Math.sqrt(a*a+b*b);
            rad = Math.atan2(a,b);
            if(rad<0)rad+=Math.PI*2;
            deg = rad/Math.PI*180;
            sin = a/c;
            cos = b/c;
            tan = a/b;
            
            tf.text = "c   = "+c.toString();
            tf.appendText("\nrad = "+rad.toString());
            tf.appendText("\ndeg = "+deg.toString());
            tf.appendText("\nsin = "+sin.toString());
            tf.appendText("\nsin = "+Math.sin(rad).toString());
            tf.appendText("\ncos = "+cos.toString());
            tf.appendText("\ntan = "+tan.toString());
            
            var r:Number= 100/c;
            s.graphics.lineStyle(1,0xaaaaaa);
            s.graphics.drawCircle(0,0,r*c);
            s.graphics.moveTo(0,-400);
            s.graphics.lineTo(0,400);
            s.graphics.moveTo(-400,0);
            s.graphics.lineTo(400,0);
            s.graphics.lineStyle(1,0x000000);
            s.graphics.moveTo(0,0);
            s.graphics.lineTo(b*r,a*r);//c
            s.graphics.lineTo(r*b,0);//a
            s.graphics.lineTo(0,0);//b
            
            ac.graphics.clear();
            ac.draw_arc(200,200,c*r,0,rad,10);
            
        }

    }
}

import flash.display.Sprite;
    class arc extends Sprite {
        private var my_canvas:Sprite = new Sprite();
        public function arc() {
            addChild(my_canvas);
            //graphics.lineStyle(1,0xff0000,1);
            //draw_arc(250,200,150,14,180,1);
        }
        public function draw_arc(center_x:Number , center_y:Number, radius:Number,
                                            angle_from:Number, angle_to:Number, precision:Number):void{
            //graphics.clear();
            graphics.lineStyle(1,0xff0000,1);
            var angle_diff:Number = angle_to - angle_from;
            var steps:Number = Math.round(angle_diff * precision);
            var angle:Number=angle_from;
            var px:Number = center_x + radius * Math.cos(angle);
            var py:Number = center_y + radius * Math.sin(angle);
            graphics.moveTo(px, py);
            for (var i:int=1; i<=steps; i++) {
                angle = angle_from + angle_diff / steps * i;
                px = center_x + radius * Math.cos(angle);
                py = center_y + radius * Math.sin(angle);
                graphics.lineTo(px,py);
            }
        }
    }