前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >as3--简单的文字提示队列

as3--简单的文字提示队列

作者头像
meteoric
发布2018-11-16 15:45:52
5960
发布2018-11-16 15:45:52
举报
文章被收录于专栏:游戏杂谈

_______________________________________________________________

设定队列长度为3,超出的长度,直接调用其消失方法即可。唯一不同的是,注意添加参数overwrite,并设置其值为1。这里有关于overwrite值的详情介绍:

OverwriteManager – control how (and if and when) tweens get overwritten>>

[AS3] 请问tweenlite的overwrite问题>>

code:

代码语言:javascript
复制
1: package  

       2: {

       3:     import flash.display.Bitmap;

       4:     import flash.display.BitmapData;

       5:     import flash.display.Sprite;

       6:     import flash.filters.GlowFilter;

       7:     import flash.text.TextField;

       8:     import flash.text.TextFormat;

       9:     import flash.text.TextFormatAlign;

      10:     import gs.TweenLite;

      11:     /**

      12:      * ...

      13:      * @author Meteoric

      14:      */

      15:     public class TextMessage extends Sprite

      16:     {

      17:         private var textFormat:TextFormat = new TextFormat("Arial", 14, 0x00FF00, true);

      18:         private var glowFilter:GlowFilter = new GlowFilter(0x000000, 0.7, 2, 2, 12, 5);

      19:         

      20:         private var txtArr:Array = [];

      21:         private var tweenArr:Array = [];

      22:         

      23:         private var defaultY:Number = 80;

      24:         

      25:         public function TextMessage() 

      26:         {

      27:             this.mouseEnabled = false;

      28:             this.mouseChildren = false;

      29:         }

      30:         

      31:         public function addText(txt:String, isHTML:Boolean = false):void

      32:         {

      33:             textFormat.letterSpacing = 2;

      34:             

      35:             var sprite:Sprite = new Sprite();

      36:             addChild(sprite);

      37:             

      38:             var textField:TextField = new TextField;

      39:             textField.autoSize = TextFormatAlign.LEFT;

      40:             textField.htmlText = txt;

      41:             

      42:             if (!isHTML) 

      43:             {

      44:                 textField.setTextFormat(textFormat);

      45:             }

      46:             

      47:             var bmp:Bitmap = new Bitmap();

      48:             var bmpData:BitmapData = new BitmapData(textField.width, textField.height, true, 0x00000000);

      49:             bmpData.draw(textField);

      50:             

      51:             bmp.bitmapData = bmpData;

      52:             bmp.x = -bmp.width / 2;

      53:             bmp.filters = [glowFilter];

      54:             bmp.smoothing = true;

      55:             

      56:             sprite.addChild(bmp);

      57:             

      58:             sprite.width = bmp.width * 1.3;

      59:             sprite.height = bmp.height * 1.3;

      60:             sprite.x = 200;

      61:             sprite.y = 120;

      62:             

      63:             txtArr.push(sprite);

      64:             

      65:             var aryLen:int = txtArr.length;

      66:             

      67:             for (var i:int = 0, len:int = aryLen - 3; i < len; i++)

      68:             {

      69:                 var tempSprite:Sprite = txtArr[i] as Sprite;

      70:                 

      71:                 TweenLite.to(tempSprite, 0.2, {width:sprite.width, height:sprite.height, alpha:0, onComplete:onCompleteFunc, onCompleteParams:[tempSprite], overwrite:1});

      72:             }

      73:             

      74:             TweenLite.to(sprite, 0.2, {width:bmp.width, height:bmp.height, overwrite:1});

      75:             TweenLite.to(sprite, 0.4, {width:sprite.width, height:sprite.height, alpha:0, delay:3, onComplete:onCompleteFunc, onCompleteParams:[sprite], overwrite:0});

      76:             

      77:             len = aryLen > 3 ? aryLen - 3 : 0;

      78:             for (i = aryLen - 1; i >= len; i--)

      79:             {

      80:                 var _y:int = -27 * (aryLen - i - 1) + 100;

      81:                 TweenLite.to(txtArr[i], 0.2+(aryLen-i-1)*0.2, {y:_y,overwrite:0});

      82:             }            

      83:         }

      84:         

      85:         private function onCompleteFunc(param_1:Sprite):void 

      86:         {

      87:             

      88:             var len:int = txtArr.length;

      89:             

      90:             for (var i:int = 0; i <  len; i++)

      91:             {

      92:                 if (txtArr[i] == param_1)

      93:                 {

      94:                     var bmp:Bitmap = param_1.getChildAt(0) as Bitmap;

      95:                     bmp.bitmapData.dispose();

      96:                     param_1.removeChild(bmp);

      97:                     bmp = null;

      98:                     txtArr.splice(i,1);                    

      99:                     this.removeChild(param_1);

     100:                     param_1 = null;

     101:                     break;

     102:                 }

     103:             }

     104:         }

     105:         

     106:     }

     107:  

     108: }
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2012-10-30 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档