博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
as3--简单的文字提示队列
阅读量:6229 次
发布时间:2019-06-21

本文共 3932 字,大约阅读时间需要 13 分钟。

_______________________________________________________________

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

 

code:

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: }

转载地址:http://lrtna.baihongyu.com/

你可能感兴趣的文章
px和em和rem的区别
查看>>
OSChina 周六乱弹 —— “我们”快被你们玩坏了
查看>>
OSChina 周四乱弹 ——00后让别人给自己网购女朋友
查看>>
OSChina 周六乱弹 ——程序员的情怀:贫贱不能移
查看>>
螺旋矩阵
查看>>
SQLserver From simple To Full backup model
查看>>
一个不错的图片
查看>>
win32学习07.Windows消息机制
查看>>
Spring中使用import整合多个配置文件
查看>>
简单工厂模式
查看>>
热门搜索和历史搜索的设计思想
查看>>
php cgi模式下获取执行文件的完整路径
查看>>
防SQL注入过滤器的实现
查看>>
Android在onCreate()中获得控件尺寸
查看>>
php设置虚拟目录
查看>>
计算机是如何做加法的?(4)——构建半加器的初步设想
查看>>
最近打算把string_h下面的函数都实现一遍
查看>>
farpoint合计列不参与排序实现方法
查看>>
嵌入式Linux C语言基础——ARM Linux内核常见数据结构
查看>>
原理剖析(第 006 篇)Semaphore工作原理分析
查看>>