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

MathDraw

Math使って遊んでみただけです。
三角関数楽しいなぁ。
Get Adobe Flash player
by rettuce 05 Feb 2011
    Embed
/**
 * Copyright rettuce ( http://wonderfl.net/user/rettuce )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/bDT5
 */

package 
{
    import flash.display.Graphics;
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.geom.Point;
        
    [SWF(width = 465, height = 465, backgroundColor = 0x000000, frameRate = 60)]
    /**
     * ...
     * @author rettuce
     * 
     */
    public class Main extends MovieClip 
    {
        private var _spr:Sprite;
        private var _gc:Graphics;
        private var _speed:Number = 1;            //   1,
        private var _speedc:Number = 110;        // 110,
        private var _color:Number = 0xFFFFFF;
        private var _counter:Number = 0;
        private var _point:Point= new Point(0,0);
                
        public function Main()
        {
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init );
        }
        
        private function init(e:Event = null ):void
        {
            removeEventListener(Event.ADDED_TO_STAGE, init );            
            stage.addEventListener(MouseEvent.CLICK, function() {                
                _speed = Math.random()*Math.random();
                _speedc= 200*Math.random();                
                _color = 0xFFFFFFF*Math.random();
                _gc.clear();
            });

            drawSet();
            
            loaderInfo.addEventListener(Event.UNLOAD, function(e:Event):void {
                stage.removeEventListener(MouseEvent.CLICK, function(e:MouseEvent):void{} );
                loaderInfo.removeEventListener(Event.UNLOAD, arguments.callee );
            });
        }
        
        private function drawSet():void 
        {
            var _spr:Sprite = new Sprite();
            addChild(_spr);
            _gc = _spr.graphics;
            addEventListener(Event.ENTER_FRAME, drawAnimation );
        }
        
        private function drawAnimation(e:Event)
        {            
            var ta:Number = _counter*Math.PI/2;
            _point.x = Math.cos(ta)*150+stage.stageWidth/2;
            _point.y = Math.sin(ta)*150+stage.stageHeight/2
            _gc.lineTo(Math.cos(_counter*_speedc)*100+_point.x, Math.sin(_counter*_speedc)*100+_point.y);
            _gc.lineStyle (1, _color, 1);
            _counter += _speed;
        }
    }
    
}