MLT

[xat.com] blast.as

MLT
Nov 11th, 2013
524
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Security.allowDomain("xat.com");
  2. Security.allowDomain("www.xatech.com");
  3.  
  4. var Args, FV;
  5. var Options = {};
  6.  
  7. stop(); // wait for it
  8.  
  9. function Go(a) // start!
  10. {
  11.     Args = a;
  12.    
  13.     if(this['TweekGo'] is Function) this['TweekGo']();
  14.    
  15.     this.scaleX = Args.WW / 728;
  16.     this.scaleY = Args.HH / 486;
  17.     FV = xInt(Capabilities.version.split(' ')[1]);
  18.     addEventListener(Event.ENTER_FRAME, Tick);
  19.     play();
  20. }
  21.  
  22.  
  23. function Tick(e)
  24. {
  25.     if(FV > 9)gotoAndPlay(currentFrame);
  26.     ColorList(Args, this); // color stuff
  27.     if(currentFrame == totalFrames)
  28.     {
  29.         stop();
  30.         if(Args.Done) Args.Done(); // end it           
  31.     }
  32. }
  33.  
  34. function createTextNoWrap(mc, boxX:Number, boxY:Number, boxWidth:Number, boxHeight:Number,
  35.     boxText:String, fillColor:Number, shadColor:Number, fillAlpha:Number, rot:Number,
  36.     size:Number, align:String, Flags:Number)
  37. {
  38.  
  39.     var rClip;
  40.      boxX = int(boxX);
  41.      boxY = int(boxY);
  42.      boxWidth = int(boxWidth);
  43.      boxHeight = int(boxHeight);
  44. /*
  45.      if(1) with(mc) { // draw a box for debugging
  46.         lineStyle(1, 0x808080, 100);
  47.         moveTo(boxX, boxY);
  48.         lineTo(boxX, boxY+boxHeight);
  49.         lineTo(boxX+boxWidth, boxY+boxHeight);
  50.         lineTo(boxX+boxWidth, boxY);
  51.         lineTo(boxX, boxY);
  52.      }
  53. */
  54.  
  55.     var mcFmt;
  56.    
  57.     mcFmt = new TextFormat();
  58.  
  59.     mcFmt.align = align;
  60.     mcFmt.bold = true;
  61.     mcFmt.color = fillColor;
  62.  
  63.     mcFmt.font = "_sans";
  64.     mcFmt.size = size;
  65.    
  66.     // main text 1
  67.    
  68.     ////var m = mc.createTextField("mcTxt" + _root.depth , d, boxX+1, 1+boxY, boxWidth-1*2, boxHeight-1*2);
  69.    
  70.     var m = new TextField();
  71.    
  72.     m.x = boxX+1;
  73.     m.y = 1+boxY;
  74.     m.width = boxWidth-1*2;
  75.     m.height = boxHeight-1*2;
  76.     m.autoSize = align;//TextFieldAutoSize.NONE;  
  77.     m.selectable = true;
  78.     m.defaultTextFormat = mcFmt;           
  79.     m.text = boxText;
  80.     mc.addChild(m);
  81.  
  82. //todo          m.autoSize = align;
  83.  
  84.     if(Flags & 2)
  85.     {
  86.         m.multiline = true;
  87.         m.wordWrap=true;
  88.     }
  89.  
  90.     if(m.width > boxWidth-1*2) // it doesn't fit
  91.     {
  92.         var FontFitSize:Number = mcFmt.size * (((boxWidth-1*2) / m.width)) - 0.5;
  93.         var FontSteps:Number = 4;
  94.         var FontInc = (mcFmt.size - FontFitSize) / FontSteps;
  95.         if(FontInc < 1) FontInc = 1;
  96.        
  97.         while((m.width > boxWidth-1*2) && (mcFmt.size > 1))
  98.         {
  99.             mcFmt.size -=  FontInc;
  100.             m.defaultTextFormat = mcFmt;           
  101.             m.text = boxText;
  102.         }
  103.     }
  104.    
  105.     m.y = boxY+int((boxHeight - m.height) / 2) - 1; // centre vertically
  106.     ////m.rotation = rot;
  107. /*         
  108.     if(Flags == undefined)
  109.     {
  110.     // shadow texts
  111.     mcFmt.color = shadColor;
  112.        
  113.         for (y=0; y<3; y++) {
  114.             for (x=0; x<3; x++) {
  115.                 if(x==1 && y==1) continue;
  116.  
  117.                 //PageObject.push(
  118.                 _root.depth++;
  119.                 mc.createTextField("mcTxt" + _root.depth, _root.depth, boxX+1+x*1-1, m._y+y*1-1, boxWidth-1*2, boxHeight-1*2);
  120.                 rClip = mc["mcTxt" + _root.depth];
  121.                 rClip.text = boxText;
  122.                 //if(rot != 0)
  123.                 //  rClip.embedFonts = true;
  124.                 //rClip._rotation = rot;
  125.                 rClip.autoSize = align;
  126.                 rClip.setTextFormat(mcFmt);
  127.             }
  128.         }
  129.      }
  130.     _root.depth = d+1;
  131.     */
  132.     return m;
  133. }
  134.  
  135. const hcolor = { col0:0, col1:1, col2:2, col3:3, Back:0, Col:0}; // Color instance name lookup
  136.    
  137. function ColorList(mc, container:DisplayObjectContainer, indentString:String = ""):Boolean
  138. {
  139.     var child:DisplayObject;
  140.     var Cycling:Boolean = false;
  141.    
  142.     for(var i:uint=0; i<container.numChildren;i++)
  143.     {
  144.         child = container.getChildAt(i);
  145.        
  146.         if(child==null) continue;
  147.        
  148.         if(child.name.substr(0, 4) == "Text") // found Text ?
  149.         {
  150.             if(MovieClip(child).Text) continue; // skip if done
  151.             MovieClip(child).Text = true;
  152.             var n = xInt(child.name.substr(4));
  153.             if(!Args.Text) continue;
  154.             if(!Args.Text[n]) n = 0;
  155.             {
  156.                 var Col = 0xFFFFFF; // default white
  157.                 if(Options.TextCols)
  158.                 {
  159.                     Col = Options.TextCols[n];
  160.                     if(Col == undefined) Col = 0xFFFFFF;
  161.                 }
  162.                 createTextNoWrap(child, 0, 0, child.width, child.height, Args.Text[n], Col, 0, 1, 0, 22, "center", 0);
  163.             }
  164.             continue;
  165.         }
  166.        
  167.         var col = hcolor[child.name];
  168. //trace(indentString, child, child.name,col,child.transform.colorTransform.color);
  169.         if(col!= undefined)
  170.         {
  171.             col = mc.Cols[col];
  172.             if(col == undefined) col = mc.Cols[0];
  173.             //if(col == 'y' || child.transform.colorTransform.color==0) //if color it AND not yet colored
  174.             {/*
  175.                 if(col == 'y')
  176.                 {
  177.                     col = cc;
  178.                     Cycling = true;
  179.                 }*/
  180.                 if(col==0) col = 1; //bodge black transform
  181. //trace("col>>>", indentString, child.name, mc.name, col);                     
  182.                 var c = new ColorTransform();
  183.                 c.color = col;
  184.                 child.transform.colorTransform = c;        
  185.             }
  186.             //DidColor = true; // we found something to color
  187.             continue;//return Cycling; // no point in going deeper
  188.         }
  189.  
  190.  
  191.         if(container.getChildAt(i) is DisplayObjectContainer)
  192.         {
  193.             var t = ColorList(mc, DisplayObjectContainer(child), indentString + "    ");
  194.             Cycling ||= t;
  195.         }
  196.     }
  197.     return Cycling;
  198. }      
  199.  
  200. function xInt(arg):Number
  201. // guaranteed to return a number
  202. {
  203.     var r:Number = parseInt(String(arg));
  204.  
  205.     if (isNaN(r)) return 0;// return 0 if NaN
  206.  
  207.     return r;
  208. }
Advertisement