getTimer()函數getTimer()函數
public function getTimer():int
這個方法會傳回自從 ActionScript 3.0 (AVM2) 的 Flash 執行階段虛擬機器啟動後的毫秒數。
1000615_getTimer.swf
import flash.display.MovieClip;
import flash.text.TextFormat;
import flash.text.TextField;
import fl.controls.UIScrollBar;
import fl.controls.ScrollBarDirection;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.ui.Mouse;
var vScrollBar:UIScrollBar;
this.createUIScrollBar();
this.setInfoTF();
var startTime1:Number = getTimer();
trace(this.startTime1);
click.buttonMode = true;
click.addEventListener(MouseEvent.CLICK,clickHandler);
function clickHandler(event:MouseEvent):void {
trace(getTimer()-this.startTime1);
this.addInfo(getTimer()-this.startTime1);
/*強制捲軸立即更新其捲動屬性。 - 重要,否則捲軸拖曳Bar會不見*/
this.vScrollBar.scrollPosition = this.vScrollBar.maxScrollPosition;
trace("this.vScrollBar.scrollPosition : " + this.vScrollBar.scrollPosition);
this.vScrollBar.update();
return;
}
/*設置info動態文字欄位屬性*/
function setInfoTF():void {
var format:TextFormat = new TextFormat();
format.color = 0xFFFFFF;
format.size = 24;
this.info.selectable = true;
this.info.wordWrap = true;
/*autoSize屬性不能開, 否則捲軸會不正常*/
/*this.info.autoSize = TextFieldAutoSize.LEFT;*/
this.info.setTextFormat(format);
this.info.defaultTextFormat = format;
return;
}
/*附加字串至TextField 欄位目前字串之後*/
function addInfo(_obj:*):void {
this.info.appendText(_obj.toString() + "\n");
return;
}
/*初始定義UIScrollBar屬性*/
function createUIScrollBar():void {
this.vScrollBar = new UIScrollBar();
this.vScrollBar.direction = ScrollBarDirection.VERTICAL;
this.vScrollBar.scrollTarget = info;
this.vScrollBar.move(info.x + info.width + 10, info.y);
this.vScrollBar.height = info.height;
this.addChild(this.vScrollBar);
return;
}
沒有留言:
張貼留言