MLT icon

[xat.com] blast.as

MLT | PRO | 11/11/13 09:57:44 PM UTC | 0 ⭐ | 10742 👁️ | Never ⏰ | []
ActionScript |

4.88 KB

|

None

|

0 👍

/

0 👎

Security.allowDomain("xat.com");
Security.allowDomain("www.xatech.com");
 
var Args, FV;
var Options = {};
 
stop(); // wait for it
 
function Go(a) // start!
{
    Args = a;
    
    if(this['TweekGo'] is Function) this['TweekGo']();
    
    this.scaleX = Args.WW / 728;
    this.scaleY = Args.HH / 486;
    FV = xInt(Capabilities.version.split(' ')[1]);
    addEventListener(Event.ENTER_FRAME, Tick);
    play();
}
 
 
function Tick(e)
{
    if(FV > 9)gotoAndPlay(currentFrame);
    ColorList(Args, this); // color stuff
    if(currentFrame == totalFrames)
    {
        stop();
        if(Args.Done) Args.Done(); // end it            
    }
}
 
function createTextNoWrap(mc, boxX:Number, boxY:Number, boxWidth:Number, boxHeight:Number,
    boxText:String, fillColor:Number, shadColor:Number, fillAlpha:Number, rot:Number, 
    size:Number, align:String, Flags:Number)
{
 
    var rClip;
     boxX = int(boxX);
     boxY = int(boxY);
     boxWidth = int(boxWidth);
     boxHeight = int(boxHeight);
/*
     if(1) with(mc) { // draw a box for debugging
        lineStyle(1, 0x808080, 100);
        moveTo(boxX, boxY);
        lineTo(boxX, boxY+boxHeight);
        lineTo(boxX+boxWidth, boxY+boxHeight);
        lineTo(boxX+boxWidth, boxY);
        lineTo(boxX, boxY);
     }
*/
 
    var mcFmt; 
    
    mcFmt = new TextFormat();
 
    mcFmt.align = align;
    mcFmt.bold = true;
    mcFmt.color = fillColor;
 
    mcFmt.font = "_sans";
    mcFmt.size = size;
    
    // main text 1
    
    ////var m = mc.createTextField("mcTxt" + _root.depth , d, boxX+1, 1+boxY, boxWidth-1*2, boxHeight-1*2);
    
    var m = new TextField();
    
    m.x = boxX+1;
    m.y = 1+boxY;
    m.width = boxWidth-1*2;
    m.height = boxHeight-1*2;
    m.autoSize = align;//TextFieldAutoSize.NONE;  
    m.selectable = true;
    m.defaultTextFormat = mcFmt;            
    m.text = boxText;
    mc.addChild(m);
 
//todo          m.autoSize = align;
 
    if(Flags & 2)
    {
        m.multiline = true;
        m.wordWrap=true;
    }
 
    if(m.width > boxWidth-1*2) // it doesn't fit
    {
        var FontFitSize:Number = mcFmt.size * (((boxWidth-1*2) / m.width)) - 0.5;
        var FontSteps:Number = 4;
        var FontInc = (mcFmt.size - FontFitSize) / FontSteps;
        if(FontInc < 1) FontInc = 1;
        
        while((m.width > boxWidth-1*2) && (mcFmt.size > 1))
        {
            mcFmt.size -=  FontInc;
            m.defaultTextFormat = mcFmt;            
            m.text = boxText;
        }
    }
    
    m.y = boxY+int((boxHeight - m.height) / 2) - 1; // centre vertically
    ////m.rotation = rot;
/*          
    if(Flags == undefined)
    {
    // shadow texts
    mcFmt.color = shadColor;
        
        for (y=0; y<3; y++) {
            for (x=0; x<3; x++) {
                if(x==1 && y==1) continue;
 
                //PageObject.push(
                _root.depth++;
                mc.createTextField("mcTxt" + _root.depth, _root.depth, boxX+1+x*1-1, m._y+y*1-1, boxWidth-1*2, boxHeight-1*2);
                rClip = mc["mcTxt" + _root.depth];
                rClip.text = boxText;
                //if(rot != 0)
                //  rClip.embedFonts = true;
                //rClip._rotation = rot;
                rClip.autoSize = align;
                rClip.setTextFormat(mcFmt);
            }
        }
     }
    _root.depth = d+1;
    */
    return m;
}
 
const hcolor = { col0:0, col1:1, col2:2, col3:3, Back:0, Col:0}; // Color instance name lookup
    
function ColorList(mc, container:DisplayObjectContainer, indentString:String = ""):Boolean
{ 
    var child:DisplayObject;
    var Cycling:Boolean = false;
    
    for(var i:uint=0; i<container.numChildren;i++) 
    { 
        child = container.getChildAt(i);
        
        if(child==null) continue;
        
        if(child.name.substr(0, 4) == "Text") // found Text ?
        {
            if(MovieClip(child).Text) continue; // skip if done
            MovieClip(child).Text = true;
            var n = xInt(child.name.substr(4));
            if(!Args.Text) continue;
            if(!Args.Text[n]) n = 0;
            {
                var Col = 0xFFFFFF; // default white
                if(Options.TextCols)
                {
                    Col = Options.TextCols[n];
                    if(Col == undefined) Col = 0xFFFFFF;
                }
                createTextNoWrap(child, 0, 0, child.width, child.height, Args.Text[n], Col, 0, 1, 0, 22, "center", 0);
            }
            continue;
        }
        
        var col = hcolor[child.name];
//trace(indentString, child, child.name,col,child.transform.colorTransform.color);
        if(col!= undefined) 
        {
            col = mc.Cols[col];
            if(col == undefined) col = mc.Cols[0];
            //if(col == 'y' || child.transform.colorTransform.color==0) //if color it AND not yet colored
            {/*
                if(col == 'y')
                {
                    col = cc;
                    Cycling = true;
                }*/
                if(col==0) col = 1; //bodge black transform
//trace("col>>>", indentString, child.name, mc.name, col);                      
                var c = new ColorTransform();
                c.color = col;
                child.transform.colorTransform = c;         
            }
            //DidColor = true; // we found something to color
            continue;//return Cycling; // no point in going deeper
        }
 
 
        if(container.getChildAt(i) is DisplayObjectContainer) 
        { 
            var t = ColorList(mc, DisplayObjectContainer(child), indentString + "    ");
            Cycling ||= t;
        } 
    } 
    return Cycling;
}       
 
function xInt(arg):Number
// guaranteed to return a number
{
    var r:Number = parseInt(String(arg));
 
    if (isNaN(r)) return 0;// return 0 if NaN
 
    return r;
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎