forked from: Hello World 4 自分のコード
forked from Hello World (diff: 20)
ActionScript3 source code
/**
* Copyright tokufxug ( http://wonderfl.net/user/tokufxug )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/zVr1
*/
// forked from tokufxug's Hello World
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.utils.Timer;
public class HelloWorld extends Sprite {
public var tf:TextField;
public function HelloWorld() {
tf = new TextField();
tf.defaultTextFormat = new TextFormat("_sans", 40);
addChild(tf);
tf.text = getGreetings();
tf.width = tf.textWidth + 20;
}
// 時間から挨拶を返却する。
private function getGreetings():String {
var h:Number = new Date().getHours();
var grtngs:String = null;
if (h >= 4 && h <= 11) {
grtngs = "おはよう";
}
if (h >= 12 && h <= 18) {
grtngs = "こんにちは";
}
if (h >= 19 && h <= 23 || h >= 0 && h <= 3) {
grtngs = "こんばんは";
}
return grtngs;
}
}
}
