淡出效果:
编写deconstructive效果很类似于编写constructive效果,当一个deconstructive效果被应用,任何的字符元件都会将他的frameCounter属性值配置为0.因此我们能够开始我们的下一行代码,以决定什么时候再次让他动起来。
如下代码:
fadeOut=function(){
if(this.frameCount >this.delay){
this.onEnterFrame=function(){
this._alpha-=10;
if(this._alpha<=0){
this.remove();
}
}
}
}
if(this.frameCount >this.delay){
this.onEnterFrame=function(){
this._alpha-=10;
if(this._alpha<=0){
this.remove();
}
}
}
}
这个效果是等待frameCounter值超过delay.然后覆盖他自身的onEnterFrame事件在每一帧上减少alpha值直到他不可见,最后字符元件调用remove将其从内存中移出。查看源文档sample3.
全部代码:
importcom.actionscript.text.TextScript;
vartf:TextFormat=newTextFormat();
tf.font="ArialBlack";
tf.bold=true;
tf.size=36;
tf.color=0x55FF55;
fadeOut=function(){
if(this.frameCount >this.delay){
this.onEnterFrame=function(){
this._alpha-=10;
if(this._alpha<=0){
this.remove();
}
}
}
}
varframeCounter:Number=0;
this.onEnterFrame=function(){
if(frameCounter e==0){
m.removeMovieClip();
m=TextScript.createEffect(this,"HelloWorld!",50,10,tf,2,function(){});
//下面的代码是轮询出每一个字符元件,因为我们没有给出constructive方法(如上例中方法为function(){},前没有给出具体的constructive方法)我们需要让他们都可见,以便显示出来destructive方法。
for(variinm){
m._visible=true;
}
TextScript.removeEffect(m,2,fadeOut);
}
}
vartf:TextFormat=newTextFormat();
tf.font="ArialBlack";
tf.bold=true;
tf.size=36;
tf.color=0x55FF55;
fadeOut=function(){
if(this.frameCount >this.delay){
this.onEnterFrame=function(){
this._alpha-=10;
if(this._alpha<=0){
this.remove();
}
}
}
}
varframeCounter:Number=0;
this.onEnterFrame=function(){
if(frameCounter e==0){
m.removeMovieClip();
m=TextScript.createEffect(this,"HelloWorld!",50,10,tf,2,function(){});
//下面的代码是轮询出每一个字符元件,因为我们没有给出constructive方法(如上例中方法为function(){},前没有给出具体的constructive方法)我们需要让他们都可见,以便显示出来destructive方法。
for(variinm){
m._visible=true;
}
TextScript.removeEffect(m,2,fadeOut);
}
}
附加演示文档:
深入:
当使用TextScript创建字体效果时,记住您使用的都是movieclip的强大功能。您能够改变字体的色彩,应用滤镜和融合效果,重建复杂的物理效果,并且不要忘记也能够使用声音或其他媒体。这个类编写的相对比较简单,但是他的伸缩性很强,加上您的一点点创意,您应能创建出更有趣的效果来。您能够在TextScript类中查看转换效果函数(从类的第108行开始).他们是内置的createEffect和removeEffect方法。假如您创建出的很酷的效果,不要忘记分享啦。J
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!



