esemio1: (vengono utilizzati un pò tutti i parametri) var myString:String = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat."; var myClip:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth()); TextBuilder.ShowText(myClip, true, 500, myString, "#333333", "verdana", 10, false, 60, Quart.easeOut, false, {myLeading:5, myAlign:"right", myBackground:"0xCCCCCC", mySelectable:true, myBorder:true}, myCallbackFunction, myClip, [15, "i'm a string", false]); function myCallbackFunction(myNumber:Number, myString:String, myBoolean:Boolean) { trace("myNumber: "+myNumber); trace("myString: "+myString); trace("myBoolean: "+myBoolean); trace("validity: "+this); }
//esempio 2 (standard) var myString:String = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat."; var myClip:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth()); TextBuilder.ShowText(myClip, true, 500, myString, "#333333", "verdana", 10, false, 60, Quart.easeOut, false, null, myCallbackFunction, myClip, [15, "i'm a string", false]); function myCallbackFunction(myNumber:Number, myString:String, myBoolean:Boolean) { trace("myNumber: "+myNumber); trace("myString: "+myString); trace("myBoolean: "+myBoolean); trace("validity: "+this); }
class TextBuilder { public static function ShowText(mc:MovieClip, direction:Boolean, wdt:Number, s:String,myColor:String, myFont:String, mySize:Number, myEmbed:Boolean, speed:Number, method:Function, alphaTrans:Boolean, myExtra:Object, callBack:Function, validity:MovieClip, param:Array){ if(!mc.TextBuilderEnterClip) mc.clipEnter=mc.createEmptyMovieClip("TextBuilderEnterClip",mc.getNextHighestDepth()); mc.myText=mc.createTextField("dynText", 1, 0, 0, wdt, 1); wdt ? (mc.myText.multiline = true, mc.myText.wordWrap = true) : (mc.myText.multiline = false,mc.myText.wordWrap = false); mc.myAlign = myExtra.myAlign ? myExtra.myAlign : "left"; mc.myLeading = myExtra.myLeading ? myExtra.myLeading : 0; myExtra.myBackground ? ( mc.myText.background = true, mc.myText.backgroundColor = myExtra.myBackground ) : mc.myText.background = false; myExtra.mySelectable ? mc.myText.selectable = true : mc.myText.selectable = false; myExtra.myBorder ? mc.myText.border = true : mc.myText.border = false; mc.myText.html = true; mc.myText.antiAliasType="advanced" mc.myText.embedFonts = myEmbed; mc.myText.autoSize = "left"; mc.clipEnter.t=0; mc.clipEnter.d=speed; mc.clipEnter.s=0; mc.clipEnter.e=s.length; mc.clipEnter.st=s; mc.clipEnter.myDirection=direction; mc.clipEnter.transAlpha=alphaTrans; mc.clipEnter.sa=mc._alpha; mc.clipEnter.ea=100; mc.firstHalfString="<TEXTFORMAT LEADING=\""+mc.myLeading+"\"><P ALIGN=\""+mc.myAlign+"\"><FONT FACE=\""+myFont+"\" SIZE=\""+mySize+"\" COLOR=\""+myColor+"\">" mc.secondHalfString="</FONT></P></TEXTFORMAT>"; mc.clipEnter.onEnterFrame=function(){ if (this.t++<this.d){ if(this.transAlpha)mc._alpha=Math.round(method(this.t,this.sa,this.ea,this.d)); if(this.myDirection){ mc.myText.htmlText=mc.firstHalfString+this.st.substr(-Math.round(method(this.t,this.s,this.e,this.d)),Math.round(method(this.t,this.s,this.e,this.d)))+mc.secondHalfString; this.tempString=this.st.substr(-Math.round(method(this.t,this.s,this.e,this.d)),Math.round(method(this.t,this.s,this.e,this.d))); } else { mc.myText.htmlText=mc.firstHalfString+this.st.substr(0,Math.round(method(this.t,this.s,this.e,this.d)))+mc.secondHalfString; this.tempString=this.st.substr(0,Math.round(method(this.t,this.s,this.e,this.d))); } } else { this.onEnterFrame=undefined; callBack.apply(validity,param); } } } public static function HideText(mc:MovieClip, direction:Boolean, speed:Number, method:Function, alphaTrans:Boolean, callBack:Function, validity:MovieClip, param:Array){ mc.clipEnter.t=0; mc.clipEnter.d=speed; mc.clipEnter.s=mc.clipEnter.tempString.length; mc.clipEnter.e=-mc.clipEnter.tempString.length; mc.clipEnter.myDirection=direction; mc.clipEnter.transAlpha=alphaTrans; mc.clipEnter.sa=mc._alpha; mc.clipEnter.ea=-mc._alpha; mc.clipEnter.onEnterFrame=function(){ if (this.t++<this.d){ if(this.transAlpha)mc._alpha=Math.round(method(this.t,this.sa,this.ea,this.d)); if(this.myDirection){ mc.myText.htmlText=mc.firstHalfString+this.tempString.substr(-Math.round(method(this.t,this.s,this.e,this.d)),Math.round(method(this.t,this.s,this.e,this.d)))+mc.secondHalfString; this.tempString=this.st.substr(-Math.round(method(this.t,this.s,this.e,this.d)),Math.round(method(this.t,this.s,this.e,this.d))); } else { mc.myText.htmlText=mc.firstHalfString+this.tempString.substr(0,Math.round(method(this.t,this.s,this.e,this.d)))+mc.secondHalfString; this.tempString=this.st.substr(0,Math.round(method(this.t,this.s,this.e,this.d))); } } else { this.onEnterFrame=undefined; callBack.apply(validity, param); } } } public static function MadeText(mc:MovieClip, wdt:Number, s:String, myColor:String, myFont:String, mySize:Number, myEmbed:Boolean , myExtra:Object){ mc.myAlign = myExtra.myAlign ? myExtra.myAlign : "left"; mc.myLeading = myExtra.tLeading ? myExtra.myLeading : 0; mc.myText=mc.createTextField("dynText", 1, 0, 0, wdt, 1); wdt ? (mc.myText.multiline = true, mc.myText.wordWrap = true) : (mc.myText.multiline = false,mc.myText.wordWrap = false); myExtra.myBackground ? ( mc.myText.background = true, mc.myText.backgroundColor = myExtra.myBackground ) : mc.myText.background = false; myExtra.mySelectable ? mc.myText.selectable = true : mc.myText.selectable = false; myExtra.myBorder ? mc.myText.border = true : mc.myText.border = false; mc.myText.html = true; mc.myText.antiAliasType="advanced"; mc.myText.embedFonts = myEmbed; mc.myText.autoSize = "left"; mc.firstHalfString="<TEXTFORMAT LEADING=\""+mc.myLeading+"\"><P ALIGN=\""+mc.myAlign+"\"><FONT FACE=\""+myFont+"\" SIZE=\""+mySize+"\" COLOR=\""+myColor+"\">" mc.secondHalfString="</FONT></P></TEXTFORMAT>"; mc.myText.htmlText=mc.firstHalfString+s+mc.secondHalfString; } }
You need to login to post a comment.
