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: forked from: flash on 2009-11-16

Get Adobe Flash player
by psyark 16 Nov 2009
/**
 * Copyright psyark ( http://wonderfl.net/user/psyark )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/eX60
 */

// forked from psyark's forked from: flash on 2009-11-16
// forked from psyark's flash on 2009-11-16
package {
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.geom.Point;
    
    public class FlashTest extends Sprite {
        private var points:Array = [];
        private var t:Number = 0;
        
        public function FlashTest() {
            for (var i:int=0; i<30; i++) {
                var p:Point = new Point();
                p.x = Math.random() * 465;
                p.y = Math.random() * 465;
                points.push(p);
            }
            addEventListener(Event.ENTER_FRAME, enterFrameHandler);
        }
        
        private function enterFrameHandler(event:Event):void {
            t = (t + 0.1) % (points.length - 1);
            
            graphics.clear();
            graphics.lineStyle(1);
            
            var p:Point = points[0];
            graphics.moveTo(p.x, p.y);
            
            for (var i:int=1; i<points.length-1; i++) {
                var b:Point = points[i];
                var c:Point = Point.interpolate(b, points[i + 1], 0.5);
                if (i < t) {
                    graphics.curveTo(b.x, b.y, c.x, c.y);
                } else {
                    var a:Point = Point.interpolate(points[i - 1], b, 0.5);
                    var d:Point = Point.interpolate(b, a, t % 1);
                    var e:Point = Point.interpolate(c, b, t % 1);
                    var f:Point = Point.interpolate(e, d, t % 1);
                    graphics.curveTo(d.x, d.y, f.x, f.y);
                    break;
                }
            }
        }
    }
}