wonderWheel
package {
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
public class Main extends Sprite {
private var bg:Sprite;
private var invButton:MovieClip;
private var line:Sprite;
private var lines:Array;
private var linesNum:Number;
public function Main():void {
init();
}
public function init():void
{
linesNum = 20;
bg = new Sprite();
bg.graphics.beginFill(0x151515);
bg.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
bg.graphics.endFill();
invButton = new MovieClip();
invButton.graphics.beginFill(0xffffff, 0);
invButton.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
invButton.graphics.endFill();
invButton.addEventListener(MouseEvent.MOUSE_DOWN,onDown);
invButton.addEventListener(MouseEvent.MOUSE_UP,onUp);
addChild(bg);
addChild(invButton);
lines = new Array();
for (var i:Number = 0; i < linesNum; i++) {
line = new Sprite;
lines[i] = line;
line.x = 250
line.y = 250;
addChildAt(line, 1);
invButton.addEventListener(Event.ENTER_FRAME, onFrame);
}
}
public function onMove(event:MouseEvent):void {
for (var i:Number = 0; i < linesNum; i++) {
line=lines[i] ;
line.graphics.lineTo(line.mouseX,line.mouseY);
}
}
public function onDown(event:MouseEvent):void {
for (var i:Number = 0; i < linesNum; i++)
{
line=lines[i];
line.graphics.clear();
line.graphics.lineStyle(1, Math.random()*0xFFFFFF,1);
line.graphics.moveTo(line.mouseX, line.mouseY);
}
invButton.addEventListener(MouseEvent.MOUSE_MOVE, onMove);
}
public function onFrame(event:Event):void
{
for (var i:Number = 0; i < linesNum; i++)
{
line = lines[i] ;
line.rotation += i*.5;
}
}
public function onUp(event:MouseEvent):void {
invButton.removeEventListener(MouseEvent.MOUSE_MOVE, onMove);
}
}
}