forked from: rollPrate
前自分が作ったやつを時計風に
// forked from venthels's rollPrate
package {
import flash.text.TextField;
import flash.display.*;
import flash.events.*;
import flash.geom.Point;
[SWF(width="465", height="465", backgroundColor="0xFFFFFF", frameRate="30")]
public class rollPrate extends Sprite {
private var sp:Sprite;
private var prate:Sprite;
private var o:Sprite;
private var mPt:Point;
private var mPPt:Point = new Point();
private var dragFlg:Boolean;
private var rad:Number;
private var tf:TextField = new TextField();
public function rollPrate():void {
sp = new Sprite();
stage.addChild(sp);
sp.x = stage.stageWidth/2;
sp.y = stage.stageHeight/2;
tf.x = 100;
sp.addChild(tf);
prate = new Sprite();
sp.addChild(prate);
var g:Graphics = prate.graphics;
g.lineStyle(1, 0x000000, 1.0);
g.beginFill(0xcccccc, 0.7);
g.drawRect(0, 0, 100, 70);
o = new Sprite();
sp.addChild(o);
o.graphics.beginFill(0xff0000, 0.7);
o.graphics.drawCircle(0, 0, 6);
stage.addEventListener(MouseEvent.MOUSE_DOWN, MDown);
sp.addEventListener(Event.ENTER_FRAME, loop);
}
private function MDown(e:MouseEvent):void {
dragFlg = true;
prate.x -= sp.mouseX;
prate.y -= sp.mouseY;
sp.x = stage.mouseX;
sp.y = stage.mouseY;
o.x = sp.mouseX;
o.y = sp.mouseY;
stage.addEventListener(MouseEvent.MOUSE_MOVE, MouseMove);
stage.addEventListener(MouseEvent.MOUSE_UP, MouseUp);
}
private function MouseMove(e:MouseEvent):void {
mPt = new Point(stage.mouseX, stage.mouseY);
rad = Math.atan2(mPPt.y-mPt.y, mPPt.x-mPt.x);
mPPt = mPt;
}
private function MouseUp(e:MouseEvent):void {
dragFlg = false;
stage.removeEventListener(MouseEvent.MOUSE_MOVE, MouseMove);
stage.removeEventListener(MouseEvent.MOUSE_UP, MouseUp);
}
private function loop(e:Event):void {
//if(dragFlg)
//sp.rotation = rad*180/Math.PI;
sp.rotation += 2 ;
var date:Date = new Date();
//sp.rotation = date.seconds * 360 / 60;
tf.text = String(date.seconds);
}
}
}