Test - Data
♥0 |
Line 41 |
Modified 2011-05-21 13:15:36 |
MIT License
archived:2017-03-20 05:15:44
ActionScript3 source code
/**
* Copyright ne_ ( http://wonderfl.net/user/ne_ )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/cMPZ
*/
package {
import flash.events.TimerEvent;
import flash.utils.Timer;
import flash.text.TextField;
import flash.display.Sprite;
public class Test extends Sprite {
private var campo:TextField = new TextField();
private var _meses:Array = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio","Junho","Julho",
"Agosto","Setembro","Outrubro","Novembro","Dezembro"];
private var _semana:Array = ["Domingo","Segunda","Terça","Quarta","Quinta","Sexta","Sábado"];
private var timer:Timer = new Timer(1000);
private var all:Array = new Array(8);
public function Test() {
campo.width = stage.stageWidth;
campo.height = stage.stageHeight;
addChild(campo);
timer.addEventListener(TimerEvent.TIMER, tick);
timer.start();
}
private function tick (e:TimerEvent):void{
var d:Date = new Date();
//dia do mes
all[0] = ck(d.getDate());
//mes
all[1] = ck(d.getMonth());
//ano
all[2] = String(d.getFullYear());
// dia da semana
all[3] = _semana[d.getDay()];
//mes
all[4] = _meses[d.getMonth()];
//hora
all[5] = ck(d.getHours());
//minuto
all[6] = ck(d.getMinutes());
//segundo
all[7] = ck(d.getSeconds());
//trace da array.
campo.text = all.toString() +"\n";
//composições:
campo.appendText("Hoje é dia " + all[0]+" de " + all[4]+" de "+ all[2]);
campo.appendText(" e são " + all[5] + " horas, " + all[6]+" minutos e " + all[7]+" segundos \n");
campo.appendText("Info: " + all[5]+":" + all[6] + ":" + all[7]);
}
private function ck (n:Number):String{
var s:String = String(n);
s.length < 2 ? s = "0" + s : null;
return s;
}
}
}