Game Development Reference
In-Depth Information
if (profilerDisplayOnScreen) {
profilerBitmap.y = 20;
profilerBitmap.x = 0;
}else {
profilerBitmap.x = stage.width + 10;
}
addChild(profilerBitmap);
format.align = "center";
format.size=24;
format.font="Arial";
format.color = 0xffffff
format.bold = true;
messageTextField.defaultTextFormat = format;
messageTextField.text = "Profiling\nOptimal\nFrame Rate";
messageTextField.width=200;
messageTextField.height = 200;
messageTextField.x = 100;
messageTextField.y = 100;
addChild(messageTextField);
for (var ctr:int = 0; ctr < profilerRenderObjects; ctr ++) {
profileAddObject()
}
profilerRenderFrames = profilerRenderLoops * profilerFrameRate;
addEventListener(Event.ENTER_FRAME, runProfile);
}
private function runProfile(e:Event):void {
profileUpdate();
profileRender();
if (frameCounter.countFrames()) {
profilerFrameRateTotal += frameCounter.lastframecount;
profilerFrameRateEventCounter++;
messageTextField.text = "Profiling\nOptimal\nFrame Rate\n" +
String(int(profilerFrameCount / profilerRenderFrames * 100)) + "%";
profilerFrameRateArray.push(frameCounter.lastframecount);
}
profilerFrameCount++;
if (profilerFrameCount > profilerRenderFrames) {
profileCalculate();
}
}
private function profileCalculate():void {
profilerFrameRateAverage = profilerFrameRateTotal / profilerFrameRateEventCounter;
dispose();
Search WWH ::




Custom Search