/**
* Copyright tepe ( http://wonderfl.net/user/tepe )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/oZ5H
*/
package {
import flash.display.Sprite;
import flash.events.*;
public class FlashTest extends Sprite {
private var ui:ui001 = new ui001();
public function FlashTest() {
// write as3 code here..
//var ui:ui001 = new ui001();
ui.x = 233;
ui.y = 233;
graphics.beginFill(0);
graphics.drawRect(0,0,466,466);
graphics.endFill();
addChild(ui);
addEventListener(Event.ENTER_FRAME,onFrame);
}
private var a:Number=0;
private function onFrame(e:Event):void{
var time:Date = new Date();
a = time.time;
a %= 1000*6;
ui.draw(a*Math.PI/(500*6));
}
}
}
import flash.display.*;
import flash.text.*;
import flash.events.*;
import flash.geom.*;
class ui001 extends Sprite{
private var list:Array;
//private var color1:uint = 0x114411;//緑
//private var color2:uint = 0x22ff33;
//private var color1:uint = 0x551100;//赤
//private var color2:uint = 0xff3322;
private var color1:uint = 0x223388;//青
private var color2:uint = 0x4488ff;
private var r:Number = 100;
private var tf:TextField = new TextField();
public function ui001(){
list = new Array();
addChild(tf);
var time:Date = new Date();
tf.text = time.getHours().toString()+":"+time.getMinutes().toString()+":"+time.getSeconds().toString();
//tf.x = -r/2;
//tf.y = -r/2;
//tf.type = "input";
var Format2:TextFormat = new TextFormat();
Format2.size = r/3;
Format2.font = "impact";
Format2.color = color2;
Format2.italic = false;
tf.setTextFormat(Format2,0,tf.length);
//tf.autoSize = TextFieldAutoSize.CENTER; // サイズ整形の種類
tf.width = r*2;
tf.selectable = false;
tf.wordWrap = false; // 折り返すか?
tf.textColor = color2; // テキストの色
graphics.beginFill(color1);
graphics.drawCircle(0,0,r);
graphics.drawCircle(0,0,r*0.8);
//moveTo( center - fatness + 5, 0 );
//arcTo( 0, 0, x, y, 0, myArc, 0 );
//arcTo( 0, 0, center - fatness, center - fatness, myArc , 0 );
graphics.endFill();
//graphics.lineStyle(1,0x000000);
graphics.moveTo(0,0);
graphics.beginFill(color2);
arcTo(graphics, 0, 0, r, -Math.PI / 4, -Math.PI / 6);
graphics.moveTo(0,0);
arcTo(graphics, 0, 0, r*0.8, -Math.PI / 4, -Math.PI / 6);
graphics.endFill();
tf.x = -(tf.textWidth/2);
tf.y = -(tf.textHeight/2);
}
public function add():void{
}
public function draw(n1:Number,n2:Number=0):void{
const r2:Number = 0.86;
graphics.clear();
graphics.beginFill(color1);
graphics.drawCircle(0,0,r);
graphics.drawCircle(0,0,r*r2);
//moveTo( center - fatness + 5, 0 );
//arcTo( 0, 0, x, y, 0, myArc, 0 );
//arcTo( 0, 0, center - fatness, center - fatness, myArc , 0 );
graphics.endFill();
//graphics.lineStyle(1,0x000000);
graphics.moveTo((r*r2)*Math.cos(n2),(r*r2)*Math.sin(n2));
graphics.beginFill(color2);
arcTo(graphics, 0, 0, r, n1, n2);
//graphics.moveTo(0,0);
graphics.moveTo(r*Math.cos(n1),r*Math.sin(n1));
arcTo(graphics, 0, 0, r*r2, n1, n2);
graphics.endFill();
var time:Date = new Date();
tf.text = time.getHours().toString()+":"+time.getMinutes().toString()+":"+time.getSeconds().toString();
var Format2:TextFormat = new TextFormat();
Format2.size = r/3;
Format2.font = "impact";
Format2.color = color2;
Format2.italic = false;
tf.setTextFormat(Format2,0,tf.length);
//tf.x = -(tf.textWidth/2);
//tf.y = -(tf.textHeight/2);
}
private function arcTo(g:Graphics, x:Number, y:Number,//中心
radius:Number, //半径
startAngle:Number,//角度1
endAngle:Number//角度2
):void {
var clockwise:Boolean = startAngle < endAngle;
g.lineTo(x + radius * Math.cos(startAngle), y + radius * Math.sin(startAngle));
var i:int=0;
while(clockwise && startAngle < endAngle || !clockwise && startAngle > endAngle){
var nextAngle:Number = clockwise ? Math.min(endAngle, startAngle + Math.PI / 4)
: Math.max(endAngle, startAngle - Math.PI / 4);
var nextPos:Point = new Point(
Math.cos(nextAngle) * radius,
Math.sin(nextAngle) * radius);
var controlPos:Point = new Point(
radius * Math.tan((nextAngle - startAngle) / 2) * Math.cos(nextAngle - Math.PI / 2),
radius * Math.tan((nextAngle - startAngle) / 2) * Math.sin(nextAngle - Math.PI / 2)
);
g.curveTo(x + nextPos.x + controlPos.x, y + nextPos.y + controlPos.y, x + nextPos.x, y + nextPos.y);
startAngle = nextAngle;
i++;
if(i>20)break;
}
}
}