Game Development Reference
In-Depth Information
addChild(memoryUsed);
}
public function setTextColor(color:uint):void {
format.color = String(color);
}
public function countFrames():Boolean {
frameCtr++;
if (getTimer() >= frameLast + 1000) {
lastframecount = frameCtr;
if (showProfiledRate) {
framectrText = frameCtr.toString() + "/" + profiledRate;
}else{
framectrText = frameCtr.toString();
}
framectrTextField.text =framectrText;
frameCtr = 0;
frameLast = getTimer();
memoryUsedText = String(System.totalMemory / 1024);
trace(memoryUsedText);
memoryUsed.text=memoryUsedText+"kb";
return(true);
}else {
return(false);
}
}
} // end class
} // end package
Let's take a look at the technical specification for the FrameCounter class, starting with the public
variables:
public var lastframecount:int : This variable holds the frame count for the most
recent completed 1,000-millisecond event.
public var showProfiledRate:Boolean : This Boolean is set outside, in Main , to
determine whether or not to show the frame rate as current/profiled if true . If false , it will
just show the current rate.
public var profiledRate:int : This one holds the rate-profiled frame rate if it needs to
be displayed.
The private variables come next:
private var format:TextFormat : The format for text display
private var framectrText:String : The String representing the current frame count
value
Search WWH ::




Custom Search