Posted By

burnandbass on 04/28/11


Tagged


Versions (?)

Drag/drop/scale/move DebugUtil with TransformManager


 / Published in: ActionScript 3
 

URL: http://burnandbass.com/demo15/

You need the greensock's TransformManager class, it is paid, but worth it. I use this class for debugging purposes, to move at runtime objects at the scene.

Use MagicDevugger.create(passSomeSprite); and you can transform all children of passSomeSprite

  1. package bassta.debug {
  2.  
  3. import com.greensock.transform.TransformManager;
  4. import com.greensock.events.TransformEvent;
  5. import com.greensock.transform.TransformItem;
  6. import flash.display.DisplayObject;
  7. import flash.display.DisplayObjectContainer;
  8. import flash.display.Sprite;
  9.  
  10. ///demo http://burnandbass.com/demo15/
  11.  
  12.  
  13. public class MagicDebugger {
  14.  
  15. private static var t:TransformManager;
  16. private static var c:Vector.<DisplayObjectContainer> = new Vector.<DisplayObjectContainer>
  17.  
  18. public function MagicDebugger() {
  19. throw new Error("Use only with it's static methods");
  20. }
  21.  
  22. public static function create(debuggedObject:DisplayObjectContainer):void{
  23.  
  24. if(c.indexOf(debuggedObject) == -1){
  25.  
  26. c.push(debuggedObject);
  27.  
  28. t = new TransformManager();
  29. t.allowDelete = true;
  30. t.allowMultiSelect = true;
  31. t.arrowKeysMove = true;
  32. t.forceSelectionToFront = false;
  33. t.lockScale = false;
  34. t.scaleFromCenter = false;
  35.  
  36. var i:int = debuggedObject.numChildren;
  37. for ( i >= 0; i--; ) {
  38. var s:DisplayObject = debuggedObject.getChildAt(i);
  39. t.addItem(s);
  40. t.getItem(s).addEventListener(TransformEvent.FINISH_INTERACTIVE_MOVE, outputChange);
  41. t.getItem(s).addEventListener(TransformEvent.FINISH_INTERACTIVE_ROTATE, outputChange);
  42. t.getItem(s).addEventListener(TransformEvent.FINISH_INTERACTIVE_SCALE, outputChange);
  43. t.getItem(s).addEventListener(TransformEvent.MOVE, outputChange);
  44. }
  45. } else {
  46. trace("Duplication Found");
  47. }
  48. }
  49.  
  50. private static function outputChange(event:TransformEvent):void{
  51. var currentItem:TransformItem = (event.currentTarget as TransformItem);
  52. trace("Child [ " + currentItem.targetObject.name + " ] with bounds: { x: "
  53. + Math.ceil(currentItem.x)
  54. + ", y:" + Math.ceil(currentItem.y)
  55. + ", width: " + Math.ceil(currentItem.width)
  56. + ", height: " + Math.ceil(currentItem.height)
  57. + ", rotation: " + Math.ceil(currentItem.rotation) + " }");
  58. }
  59.  
  60. public static function releaseManager():void{
  61. t.destroy();
  62. c.splice(0,c.length);
  63. }
  64.  
  65. //getter, return the manager
  66.  
  67. public static function manager():TransformManager{
  68. return t;
  69. }
  70.  
  71. }//end
  72. }

Report this snippet  

You need to login to post a comment.