Revision: 37385
Updated Code
at December 9, 2010 08:30 by adrianparr
Updated Code
package { import flash.display.Sprite; import net.hires.debug.Stats; import flash.events.MouseEvent; public class HiddenStats extends Sprite { private var _stats:Stats; public function HiddenStats() { _stats = new Stats(); _stats.visible = true; _stats.alpha = 0; _stats.scaleX = _stats.scaleY = 0.1; _stats.x = 0; _stats.y = 0; _stats.doubleClickEnabled = true; _stats.useHandCursor = false; _stats.mouseEnabled = true; _stats.mouseChildren = false; _stats.buttonMode = true; _stats.addEventListener(MouseEvent.DOUBLE_CLICK, onStats_DOUBLE_CLICK); _stats.addEventListener(MouseEvent.MOUSE_DOWN, onStats_MOUSE_DOWN); _stats.addEventListener(MouseEvent.MOUSE_UP, onStats_MOUSE_UP); addChild(_stats); } private function onStats_DOUBLE_CLICK(event:MouseEvent):void { if (_stats.alpha < 1) { _stats.alpha = 1; _stats.scaleX = _stats.scaleY = 1; _stats.useHandCursor = true; } else { _stats.alpha = 0; _stats.scaleX = _stats.scaleY = 0.1; _stats.x = _stats.y = 0; _stats.useHandCursor = false; } } private function onStats_MOUSE_DOWN(event:MouseEvent):void { _stats.startDrag(false); } private function onStats_MOUSE_UP(event:MouseEvent):void { _stats.stopDrag(); } } }
Revision: 37384
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 9, 2010 07:47 by adrianparr
Initial Code
package { import flash.display.Sprite; import net.hires.debug.Stats; import flash.events.MouseEvent; public class HiddenStats extends Sprite { private var _stats:Stats; private var _secretHitAreaRect:int = 4; public function HiddenStats() { _stats = new Stats(); _stats.visible = false; _stats.doubleClickEnabled = true; _stats.useHandCursor = true; _stats.mouseEnabled = true; _stats.mouseChildren = false; _stats.buttonMode = true; _stats.addEventListener(MouseEvent.DOUBLE_CLICK, onStats_DOUBLE_CLICK); _stats.addEventListener(MouseEvent.MOUSE_DOWN, onStats_MOUSE_DOWN); _stats.addEventListener(MouseEvent.MOUSE_UP, onStats_MOUSE_UP); addChild(_stats); stage.doubleClickEnabled = true; stage.addEventListener(MouseEvent.DOUBLE_CLICK, onStage_DOUBLE_CLICK); } private function onStats_DOUBLE_CLICK(event:MouseEvent):void { _stats.visible = false; } private function onStats_MOUSE_DOWN(event:MouseEvent):void { _stats.startDrag(false); } private function onStats_MOUSE_UP(event:MouseEvent):void { _stats.stopDrag(); } private function onStage_DOUBLE_CLICK(event:MouseEvent):void { if ((mouseX < _secretHitAreaRect) && (mouseY < _secretHitAreaRect)) { _stats.visible = true; addChild(_stats); } } } }
Initial URL
http://mrdoob.com/blog/post/582
Initial Description
For this to work you need get Mr.Doob's Stats class and put it in the 'net/hires/debug' package structure. This code basically makes the stats hidden until you double-click in the top-left corner of the stage. The stats are then draggable and can be hidden again by double-clicking the stats panel.
Initial Title
AS3 Have hidden performance stats which is made visible by double-clicking in the top-left corner of SWF
Initial Tags
Initial Language
ActionScript 3