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

centroids of sticks

Get Adobe Flash player
by freddy 04 Sep 2012
/**
 * Copyright freddy ( http://wonderfl.net/user/freddy )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/s9sz
 */

package {
    import flash.display.AVM1Movie;
    import flash.display.Shape;
    import flash.events.Event;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            // write as3 code here..
            var x:Number = 240;
            var r:Number = 30;
            var speed:Number = 0.5;
            var speedRot:Number = 10;
            var range:Number = 100;
            function create(phase:Number):Sprite {
                var t:int = 0;
                var sp:Sprite = new Sprite();
                var f:Function = function (e:Event):void {
                  sp.x = x + Math.cos(phase + t * speed * 2 * Math.PI / 30) * range;
                  sp.rotation = t * speedRot;
                  t ++;
                }
                sp.addEventListener(Event.ENTER_FRAME, f);
                return sp;
            }
            var sp:Sprite = create(0);
            sp.graphics.lineStyle(6);
            sp.graphics.moveTo(-r, 0);
            sp.graphics.lineTo(r, 0);
            sp.y = 100;
            this.addChild(sp);
            
            sp = create(Math.PI * 0.5);
            sp.graphics.lineStyle(6);
            sp.graphics.moveTo(0, 0);
            sp.graphics.lineTo(r, 0);
            sp.y = 200;
            this.addChild(sp);

            sp = create(Math.PI);
            sp.graphics.lineStyle(6);
            sp.graphics.moveTo(r * 0.75, 0);
            sp.graphics.lineTo(r, 0);
            sp.y = 300;
            this.addChild(sp);
            
            sp = create(Math.PI * 1.5);
            sp.graphics.lineStyle(6);
            sp.graphics.moveTo(r * 0.75, 0);
            sp.graphics.lineTo(r, 0);
            sp.graphics.moveTo(-r * 0.75, 0);
            sp.graphics.lineTo(-r, 0);
            sp.y = 400;
            this.addChild(sp);
        }
    }
}