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

Swallowtail Butterfly

Get Adobe Flash player
by mari 20 Feb 2009
    Embed
package {
  import flash.display.Shape;
  import flash.display.Sprite;
  import flash.events.Event;

  [SWF(width="400", height="400", backgroundColor="0xFFFFFF", frameRate="30")]

  public class Swallowtail extends Sprite {
    private const SCALE:int = 35;
    private const N:int = 1000;
    private var container:Sprite;

    public function Swallowtail() {
      container = new Sprite();
      container.x = stage.stageWidth/2;
      container.y = stage.stageHeight/2;
      addChild(container);

      var sp:Shape;
      var u:Number = 0.0, d:Number = 12.0;
      for(var i:int=0; i<N; i++) {
        u = i*d*Math.PI/N;
        sp = new Shape();
        sp.graphics.beginFill(0x00ffbf, 0.4);
        sp.graphics.drawCircle(0, 0, 2);
        sp.graphics.endFill();
        sp.x= SCALE*Math.cos(u)*(Math.exp(Math.cos(u)) - 2*Math.cos(4*u) - Math.pow(Math.sin(u/d),5.0));
        sp.y= SCALE*Math.sin(u)*(Math.exp(Math.cos(u)) - 2*Math.cos(4*u) - Math.pow(Math.sin(u/d),5.0));
        sp.z= SCALE*Math.abs(sp.y)/(d*4);
        container.addChild(sp);
      }
      container.rotationZ = -90;
      addEventListener(Event.ENTER_FRAME, onEnterFrame);
    }
    private function onEnterFrame(e:Event):void {
      container.rotationY++;
      container.rotationX++;
    }
  }
}