Guest User

Untitled

a guest
Jul 16th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. private function populateSubSections(mc:MovieClip, cntnt:Object):void
  2. {
  3. var cntnt_tot:uint = cntnt.sub.length();
  4. var cntnt_int:uint = 0;
  5.  
  6. function createSub():void
  7. {
  8. var thisSub:subsec_mc = new subsec_mc();
  9. thisSub.x = mc.width;
  10. if ( cntnt_int > 0 ) thisSub.x += 50;
  11. mc.addChild(thisSub);
  12.  
  13. panel_points[mc.name.split("_")[1]].push(thisSub.x);
  14. subNavTitles[mc.name.split("_")[1]].push(cntnt.sub[cntnt_int].nav);
  15.  
  16. fillText(MovieClip(thisSub), cntnt.sub[cntnt_int]);
  17. }
  18. createSub();
  19.  
  20. function fillText(mc:MovieClip,obj:Object):void
  21. {
  22. var tb_int:uint = 0;
  23. var tb_width:Number = 320;
  24. var tb_height:Number = 250;
  25. var tb_spacing:Number = 10;
  26.  
  27. function setTitle():void
  28. {
  29. mc.txt_title.txt.autoSize = TextFieldAutoSize.LEFT;
  30. mc.txt_title.txt.text = obj.title;
  31. /*if(mc.txt_title.width > 300){
  32. mc.txt_title.width = 300;
  33. mc.txt_title.scaleY = mc.txt_title.scaleX;
  34. }*/
  35. createTB(obj.text);
  36. }
  37. setTitle();
  38.  
  39. function createTB(str:String):void
  40. {
  41. var tf:TextField = new TextField();
  42. mc.txt_descrip.addChild(tf);
  43. if ( tb_int == 0 ) {
  44. tf.width = tb_width;
  45. tf.height = tb_height - mc.txt_title.y+mc.txt_title.height;
  46. tf.y = mc.txt_title.y+mc.txt_title.height;
  47. } else {
  48. tf.width = tb_width;
  49. tf.height = tb_height;
  50. }
  51. if ( tb_int > 0 ) tf.x = (tb_width+tb_spacing)*tb_int;
  52.  
  53. tf.multiline = true;
  54. tf.wordWrap = true;
  55. tf.selectable = false;
  56. tf.mouseWheelEnabled = false;
  57. tf.embedFonts = true;
  58. tf.antiAliasType = "normal";
  59. tf.defaultTextFormat = myTextFormat;
  60. tf.htmlText = str;
  61. tb_int++;
  62.  
  63. if ( getTextOverflow(tf).length > 0 ) {
  64. createTB(getTextOverflow(tf));
  65. } else {
  66. placeImg(mc, obj);
  67. }
  68. }
  69.  
  70. function getTextOverflow(tf:TextField):String
  71. {
  72. var overflow:String = '';
  73. for ( var i:uint = 0 ; i < tf.maxScrollV-1 ; i++ ) {
  74. overflow+=tf.getLineText(tf.bottomScrollV+i);
  75. }
  76. return overflow;
  77. }
  78. }
  79.  
  80. function placeImg(mc:MovieClip, obj:Object):void
  81. {
  82. if ( obj.img.length() > 0 && obj.img != "null" ) {
  83. loadImg();
  84. } else {
  85. mc.separator.x = mc.txt_descrip.width+20;
  86. loadnext();
  87. }
  88.  
  89. function loadImg():void {
  90. var loader:Loader = new Loader();
  91. loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
  92. var request:URLRequest = new URLRequest(assets+obj.img);
  93. loader.load(request);
  94. trace("loading: "+obj.img)
  95.  
  96. function loadComplete(e:Event):void {
  97. var image:Bitmap = new Bitmap(e.target.content.bitmapData);
  98. image.smoothing = true;
  99. mc.sub_img.addChild(image);
  100. mc.sub_img.x = mc.txt_descrip.width+25;
  101. if ( cntnt_int < cntnt_tot-1 ) {
  102. var sep:separator_mc = new separator_mc();
  103. mc.addChild(sep);
  104. sep.x = mc.width + 30
  105. }
  106. loadnext();
  107. }
  108. }
  109.  
  110. function loadnext():void {
  111. cntnt_int++;
  112. if ( cntnt_int < cntnt_tot ) {
  113. createSub();
  114. } else {
  115. fillData();
  116. }
  117. }
  118. }
  119. }
Add Comment
Please, Sign In to add comment