Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/src/LTTimer.mxml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations) (download)
Wed Aug 20 12:46:57 2008 UTC (15 years, 7 months ago) by led
File size: 3473 byte(s)
1st commit
1 <?xml version="1.0" encoding="utf-8"?>
2 <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="onInit()" viewSourceURL="srcview/index.html">
3
4 <mx:Style>
5 /* 埋め込みフォントとして使えるようにするための準備 */
6 @font-face {
7 src: url("ACE.TTF");
8 fontFamily: ACEEmbedded;
9 unicodeRange:
10 U+0030-U+0039, /* Numbers [0..9] */
11 U+0021-U+0021, /* Exclamation [!] */
12 U+003A-U+003A, /* Colon [:] */
13 U+0041-U+005A; /* Alpha [A-Z] */
14 }
15
16 global {
17 font-size: 20;
18 }
19 </mx:Style>
20
21 <mx:Script>
22 <![CDATA[
23 import mx.charts.chartClasses.DataDescription;
24 import mx.formatters.DateFormatter;
25 import mx.effects.Effect;
26
27 private const TIMER_INTERVAL:Number = 100; //mill seconds
28 private const EMERGENCY_INTERVAL:Number = 30; //seconds
29 private var _endTime:Number = 0;
30 private var _emergencyTime:Number;
31 private var _timer:Timer;
32
33 private function onInit():void{
34 // fit scale to display size
35 _clock.text = "00:77";
36 _clock.validateNow();
37 _clock.scaleX = this.width * 0.9 / _clock.textWidth;
38 _clock.scaleY = this.height* 0.9 / _clock.textHeight;
39 trace(_clock.scaleX, _clock.maxWidth , _clock.textWidth);
40
41 onStartClick();
42 }
43
44 private function onStartClick():void{
45 if(_timer) _timer.stop(); //既に動いてたら止める
46
47 _clock.setStyle("color", "#000000");
48 _endTime = new Date().getTime() + Number(_minutes.text) * 60 * 1000;
49 _emergencyTime = _endTime - EMERGENCY_INTERVAL * 1000;
50
51 _timer = new Timer(TIMER_INTERVAL, Number(_minutes.text) * 60 * 1000 / TIMER_INTERVAL);
52 _timer.addEventListener(TimerEvent.TIMER, countDown);
53 _timer.addEventListener(TimerEvent.TIMER_COMPLETE, finish);
54 _timer.start();
55 }
56
57 private function countDown(e:TimerEvent):void{
58 if(new Date().getTime() >= _emergencyTime){
59 _clock.setStyle("color", "#FF0000");
60 }
61
62 var lastTime:int = _endTime - new Date().getTime();
63 if(lastTime > 0){
64 var fommatter:DateFormatter = new DateFormatter();
65 fommatter.formatString = "NN:SS";
66 var date:Date = new Date();
67 date.setTime(lastTime);
68 _clock.text = fommatter.format(date);
69 playEffect();
70 }else if(lastTime <= 0){
71 _clock.setStyle("color", "#FFFF00");
72 _timer.dispatchEvent(new TimerEvent(TimerEvent.TIMER_COMPLETE));
73 }
74 }
75
76 private function finish(e:TimerEvent):void{
77 _clock.text = "END!";
78 _clock.alpha = 1.0;
79 _blurOff.target = _clock;
80 _blurOff.play();
81 }
82
83 private function playEffect():void{
84 var effect:Effect = _blurAndFade;
85 effect.end();
86 effect.target = _clock;
87 //effect.play();
88 }
89 ]]>
90 </mx:Script>
91
92 <mx:Parallel id="_blurAndFade">
93 <mx:Fade duration="1100"
94 alphaFrom="1.0" alphaTo="0.0"/>
95 <mx:Blur duration="1200"
96 blurXFrom="0" blurXTo="30"
97 blurYFrom="0" blurYTo="30"/>
98 </mx:Parallel>
99 <mx:Blur id="_blurOff"
100 duration="0"
101 blurXTo="0"
102 blurYTo="0"/>
103
104 <mx:TextInput x="10" y="10" width="63" id="_minutes" text="1"/>
105 <mx:Label x="81" y="12" text="分"/>
106 <mx:Button x="110" y="10" label="スタート" click="onStartClick()"/>
107 <mx:Label x="10" y="45" id="_clock" fontThickness="200" fontSize="128" width="100%" fontFamily="ACEEmbedded"/>
108 </mx:Application>

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26