flash on 2010-5-7
♥0 |
Line 50 |
Modified 2010-05-07 16:13:40 |
MIT License
archived:2017-03-20 04:53:05
ActionScript3 source code
/**
* Copyright aktm ( http://wonderfl.net/user/aktm )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/iaNJ
*/
package {
import flash.display.Sprite;
import flash.events.Event;
import mx.core.BitmapAsset;
[SWF(backgroundColor = 0xFFFFFF, width = 465, height = 465, frameRate = 1)]
public class Main2 extends Sprite {
//背景画像の読み込み、エラーが出てしまいます
//[Embed(source = "tokei.jpg")]
//public var Img001:Class;
private var _hari:Sprite;
private var _hari1:Sprite;
private var _hari2:Sprite;
private var maru:Sprite;
public function Main2() {
//背景画像の読み込みはわかりません
//var bitmapAsset:BitmapAsset = new Img001();
//addChild(bitmapAsset);
//秒針
_hari=new Sprite();
_hari.graphics.beginFill(0x000000);
_hari.graphics.drawRect(0,-165,2,165);
_hari.x = stage.stageWidth/2;
_hari.y = stage.stageHeight/2;
this.addChild(_hari);
//時針
_hari1 = new Sprite();
_hari1.graphics.beginFill(0x000000);
_hari1.graphics.drawRect(0,-130,8,130);
_hari1.x = stage.stageWidth/2;
_hari1.y = stage.stageHeight/2;
this.addChild(_hari1);
//分針
_hari2 = new Sprite();
_hari2.graphics.beginFill(0x000000);
_hari2.graphics.drawRect(0,-150,6,150);
_hari2.x = stage.stageWidth/2;
_hari2.y = stage.stageHeight/2;
this.addChild(_hari2);
//中心の円
maru = new Sprite();
maru.graphics.beginFill(0x800000);
maru.graphics.drawCircle(0,0,15);
maru.graphics.endFill();
maru.x = stage.stageWidth/2;
maru.y = stage.stageWidth/2;
this.addChild(maru);
this.addEventListener(Event.ENTER_FRAME,onEnter);
}
private function onEnter(event:Event):void{
var date:Date = new Date();
_hari.rotation = date.getSeconds()*6;
_hari2.rotation = (date.getMinutes()*6)+(date.getSeconds()/10);
var dateHour:Number=date.getHours();
if (date.getHours()>=12) {
dateHour=dateHour-12;
}
_hari1.rotation=(dateHour*30)+(date.getMinutes()/2);
}
}
}