/ Published in: ActionScript 3
                    
                                        
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.
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
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();
}
}
}
URL: http://mrdoob.com/blog/post/582
Comments
 Subscribe to comments
                    Subscribe to comments
                
                