Chapter 35 Example 18

by actionscriptbible
♥0 | Line 28 | Modified 2010-02-09 07:21:11 | 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/yPlJ
 */

package {
  import flash.display.*;
  import flash.events.MouseEvent;
  
  public class ch35ex18 extends Sprite {
    protected const NUM_COPIES:int = 6;
    public function ch35ex18() {
      for (var i:int = 0; i < NUM_COPIES; i++) {
        var copy:Shape = new Shape();
        copy.graphics.lineStyle(8, 0xE91C7A, 0.3, false);
        copy.rotationY = 70;
        copy.rotationZ = i * (360 / NUM_COPIES);
        copy.x = stage.stageWidth / 2;
        copy.y = stage.stageHeight / 2;
        addChild(copy);
      }
      stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
    }
    protected function onMouseMove(event:MouseEvent):void {
      var source:Shape = Shape(getChildAt(0));
      source.graphics.lineTo(stage.mouseX - stage.stageWidth/2,
                             stage.mouseY - stage.stageHeight/2);
      for (var i:int = 1; i < NUM_COPIES; i++) {
        var copy:Shape = getChildAt(i) as Shape;
        copy.graphics.copyFrom(source.graphics);
      }
    }
  }
}

Forked