AS3 Stats - hooked with Bassta Framework


/ Published in: ActionScript 3
Save to your folder(s)

Hi;

This is part of my new framework, the class is called Stats and is very simple stat util, click the black background to get more info, click the circle to garbage collect. It always get's on the top of the stage display list

The Grawl graphics are drawn by Bassta Draw API

demo: http://burnandbass.com/stats-bab/


Copy this code and paste it in your HTML
  1. package bassta.debug {
  2.  
  3. import bassta.structure.Initializer;
  4. import bassta.display.BTextField;
  5. import bassta.display.BSprite;
  6. import bassta.debug.Grawl;
  7. import bassta.debug.MemoryFPS;
  8. import flash.display.Stage;
  9. import flash.events.Event;
  10. import flash.events.MouseEvent;
  11. import flash.system.System;
  12.  
  13. public class Stats extends BSprite{
  14.  
  15. public function Stats() {
  16.  
  17. }
  18.  
  19. public static function create():void{
  20. var bg:BSprite = BSprite.newRect({color:"black", width:135, height:20, round:10}, {x:5, y:5, alpha:0.5, cacheAsBitmap:true, mouseChildren:true});
  21. var mem:MemoryFPS = new MemoryFPS().autoStart().attrs({x:3, y:3});
  22.  
  23. var circle:BSprite = BSprite.newCircle({radius:5, color:"white"}, {x:120, y:10, cacheAsBitmap:true, buttonMode:true});
  24.  
  25. bg.addChildren(mem, circle);
  26.  
  27. bg.addEventListener(MouseEvent.ROLL_OVER, function():void{
  28. bg.tween({time:0.5, alpha:1});
  29. });
  30.  
  31. bg.addEventListener(MouseEvent.ROLL_OUT, function():void{
  32. bg.tween({time:0.5, alpha:0.5});
  33. });
  34.  
  35. mem.addEventListener(MouseEvent.CLICK, function():void{
  36. Grawl.info(
  37. "[Stage] width: " + Initializer.stageWidth + " ; height: " + Initializer.stageHeight
  38. + "\n"
  39. + "[Memory] " + mem.currentMemory + "MB; Maximum: " + mem.memoryPeak + " MB; Free: " + mem.freeMemory
  40. + "\n"
  41. + "[FPS] " + mem.FPS + " ; Averege: " + mem.averegeFPS + " ; RunTime: " + mem.runtime + " seconds"
  42. );
  43. });
  44. circle.addEventListener(MouseEvent.CLICK, function():void{
  45. System.gc();
  46. Grawl.show("[System ] Garbage Collected!");
  47. });
  48.  
  49. Initializer.instance.stage.addChild(bg);
  50. Initializer.instance.stage.addEventListener(Event.ADDED, function():void{
  51. bg.sendFront(); //sets the Stats on the top of stage display list
  52. });
  53. }//end create()
  54.  
  55.  
  56. }//end package/class
  57. }

URL: http://burnandbass.com/stats-bab/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.