Guest User

Untitled

a guest
Jul 18th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. package
  2. {
  3. import flash.display.DisplayObject;
  4. import flash.display.Loader;
  5. import flash.display.MovieClip;
  6. import flash.display.Sprite;
  7. import flash.display.StageAlign;
  8. import flash.display.StageScaleMode;
  9. import flash.events.Event;
  10. import flash.net.URLRequest;
  11. import flash.text.TextField;
  12. /**
  13. * ...
  14. * @author kobayashi-taro
  15. */
  16. public class test extends Sprite
  17. {
  18.  
  19. public function test()
  20. {
  21. stage.align = StageAlign.TOP_LEFT;
  22. stage.scaleMode = StageScaleMode.NO_SCALE;
  23. var tf:TextField = new TextField;
  24. tf.width = stage.stageWidth;
  25. tf.height = stage.stageHeight;
  26. addChild(tf);
  27.  
  28. var id:String = loaderInfo.parameters.swf_id || '01';
  29. var ldr:Loader = new Loader;
  30. ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, function _onLoaded(event:Event):void {
  31. ldr.contentLoaderInfo.removeEventListener(Event.COMPLETE, _onLoaded);
  32. tf.text = parseMovieClip(ldr.content as MovieClip);
  33. });
  34. ldr.load(new URLRequest(id+'.swf'));
  35. }
  36.  
  37. private function parseMovieClip(mc:MovieClip, level:int = 0):String {
  38. var numChildren:int = mc.numChildren;
  39. var child:DisplayObject;
  40. var childMC:MovieClip;
  41. var childInfo:Array = [];
  42. for (var i:int = 0; i < numChildren; ++i) {
  43. child = mc.getChildAt(i);
  44. if (child is MovieClip) {
  45. childMC = child as MovieClip;
  46. childInfo.push(
  47. getSpaces(level << 2) + childMC.name
  48. );
  49. childInfo = childInfo.concat(parseMovieClip(childMC, level + 1));
  50. }
  51. }
  52.  
  53. return childInfo.join('\n');
  54. }
  55.  
  56. private function getSpaces(count:int):String {
  57. return new Array(count)
  58. .map(function (...r):String { return " "; })
  59. .join('');
  60. }
  61. }
  62.  
  63. }
Add Comment
Please, Sign In to add comment