Date と getTimer()
...
@author jc at bk-zen.com
♥0 |
Line 39 |
Modified 2009-11-27 19:18:44 |
MIT License
archived:2017-03-30 04:37:56
ActionScript3 source code
/**
* Copyright bkzen ( http://wonderfl.net/user/bkzen )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/dy3p
*/
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.utils.getTimer;
/**
* ...
* @author jc at bk-zen.com
*/
[SWF (backgroundColor = "0xFFFFFF", frameRate = "30", width = "465", height = "465")]
public class Test2 extends Sprite
{
private var txt: TextField;
private var startTimeA: uint;
private var startTimeB: uint;
private var count: int;
public function Test2()
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e: Event = null): void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
//
txt = new TextField();
txt.autoSize = TextFieldAutoSize.LEFT;
addChild(txt);
startTimeA = new Date().getTime();
startTimeB = getTimer();
addEventListener(Event.ENTER_FRAME, loop);
}
private function loop(e: Event ): void
{
if (count++ % 30 > 0) return;
var ta: uint = new Date().getTime() - startTimeA, tb: uint = getTimer() - startTimeB;
txt.text = "new Date() : " + ta + "\ngetTimer() : " + tb + "\ndiff : " + (ta - tb);
txt.x = (stage.stageWidth - txt.width) / 2;
txt.y = (stage.stageHeight - txt.height) / 2;
}
}
}