手机站
网通分站
电信主站
密 码:
用户名:
当前位置 : 主页>网页制作>Flash>列表

Flash8字体特效

来源:互联网 作者:west263.com 时间:2008-04-02
西部数码-全国虚拟主机10强!40余项虚拟主机管理功能,全国领先!双线多线虚拟主机南北访问畅通无阻!免费赠送企业邮局,.CN域名,自助建站480元起,免费试用7天,满意再付款! P4主机租用799元/月.月付免压金!


  一种简单的效果就是创建打字效果,要创建这种效果,我们将编写些效果的函数并将其附加在字符元件上。如下代码:

  代码:

  
typeOn=function(){

  if(this.frameCount >this.delay){

  this._visible=true;

  this.onEnterFrame=undefined;

  }

  }


  在打字效果中(查看源文档sample1),typeon函数附加在元件的onEnterFrame事件中,第二行是最重要的一行如下:if(this.frameCount >this.delay)-这一行不断的增加帧数并且假如帧数超过了在TextScript类所设计的delay属性值(delay的间隔时间也是以帧数为单位的),那么元件就会知道他能够开始执行动作了,在此例中的动作是把每个元件字符显示出来并清除掉onEnterFrame动作。

  此效果的任何代码:

  
importcom.actionscript.text.TextScript;

  vartf:TextFormat=newTextFormat();

  tf.font="ArialBlack";

  tf.bold=true;

  tf.size=36;

  tf.color=0x55FF55;

  typeOn=function(){

  if(this.frameCount >this.delay){

  this._visible=true;

  this.onEnterFrame=undefined;

  }

  }

  varframeCounter:Number=0;

  this.onEnterFrame=function(){

  if(frameCounter P==0){

  m.removeMovieClip();

  m=TextScript.createEffect(this,"HelloWorld!",50,10,tf,2,typeOn);

  }

  }


  旋转效果:

  

  


  这个效果仍是使用我们上面范例的方式,通过frameCounter的值来检验字符元件是否要开始动作,一旦frameCounter值超过delay值,字符元件就开自身旋转180度并且可见,然后覆盖onEnterFrame事件来动画自身旋转回初始位置。(查看源文档sample2)

  代码:

  
rotateIn=function(){

  if(this.frameCount >this.delay){

  this._rotation=-180;

  this._visible=true;

  this.onEnterFrame=function(){

  this._rotation =10;

  if(this._rotation>=0){

  this._rotation=0;

  this.onEnterFrame=undefined;

  }

  }

  }

  }


  sample2全部代码:

  
importcom.actionscript.text.TextScript;

  vartf:TextFormat=newTextFormat();

  tf.font="ArialBlack";

  tf.bold=true;

  tf.size=36;

  tf.color=0x55FF55;

  rotateIn=function(){

  if(this.frameCount >this.delay){

  this._rotation=-180;

  this._visible=true;

  this.onEnterFrame=function(){

  this._rotation =10;

  if(this._rotation>=0){

  this._rotation=0;

  this.onEnterFrame=undefined;

  }

  }

  }

  }

  varframeCounter:Number=0;

  this.onEnterFrame=function(){

  if(frameCounter p==0){

  m.removeMovieClip();

  m=TextScript.createEffect(this,"HelloWorld!",50,10,tf,2,rotateIn);

  }

  }


  Deconstructive效果

  Deconstructive效果是从场景中移除掉字符元件。他的方法名称为”removeEffect”.作为参数,他需要一个movieclip(这个movieclip是由constructive方法生成的)和Delay(两个字符元件动作之间的帧数间隔)更有我们自定义的效果。如下:

  
TextScript.removeEffect(m:MovieClip,delay:Number,effect:Function);


  关于字体元件更多的一些内容:

  §元件有一个特别的方法称为remove.他用常用来替代removeMovieClip,用来从场景中移除字符元件。他允许上一级movieclip收集任何的不用的元素并且清除掉

文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!