forked from: Chapter 34 Example 18

by actionscriptbible forked from Chapter 35 Example 18 (diff: 27)
PARTY VERSION!!!!!!!!!!!!
♥0 | Line 39 | Modified 2009-07-10 10:53:44 | MIT License
play

ActionScript3 source code

/**
 * Copyright actionscriptbible ( http://wonderfl.net/user/actionscriptbible )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/sXr7
 */

//PARTY VERSION!!!!!!!!!!!!
package {
  import flash.display.*;
  import flash.events.Event;
  
  [SWF(backgroundColor="#000000",frameRate="60")]
  public class ch34ex18 extends Sprite {
    protected const MAX_POINTS:int = 30;
    protected const NUM_COPIES:int = 6;
    protected var coordinates:Vector.<Number> = new Vector.<Number>();
    protected var commands:Vector.<int> = new Vector.<int>();
    
    public function ch34ex18() {
      for (var i:int = 0; i < NUM_COPIES; i++) {
        var copy:Shape = new Shape();
        copy.rotationY = 80;
        copy.rotationZ = i * (360 / NUM_COPIES);
        copy.x = stage.stageWidth / 2;
        copy.y = stage.stageHeight / 2;
        addChild(copy);
      }
      addEventListener(Event.ENTER_FRAME, onEnterFrame);
    }
    
    protected function onEnterFrame(event:Event):void {
      if (commands.length == MAX_POINTS) {
        commands.shift();
        coordinates.shift();
        coordinates.shift();
      }
      commands.push(GraphicsPathCommand.LINE_TO);
      coordinates.push(stage.mouseX - stage.stageWidth/2,
                       stage.mouseY - stage.stageHeight/2);
      commands[0] = GraphicsPathCommand.MOVE_TO;
      
      for (var i:int = 0; i < NUM_COPIES; i++) {
        //did you know that using copyFrom() here crashes Flash Player? :(
        var copy:Shape = getChildAt(i) as Shape;
        copy.graphics.clear();
        copy.graphics.lineStyle(13, 0xffffff, 0.7);
        copy.graphics.drawPath(commands, coordinates);
      }
    }
  }
}