//在做滚动文本之前,我们得想好这个滚动文本的基本属性 Start_x = 10; Start_y = 10; //这是滚动文本的位置 Bar_Width = 15; //这是滚动条的宽 TeBaD = 2; //这是滚动条与文本之间的间隔 Matter = "<br><font face=’楷体_GB2312’ size=’25’ color=’#FFDD00’>朦胧诗一</font><br><br><font size=’18’ color=’#FFFFFF’ face=’楷体_GB2312’>嘻嘻朋兄,笑我痴种。<br>回探心中,满怀虚若空。<br>朦朦胧胧,笑我懵懂。<br>醉入花丛,自恨太无用。<br>意有所钟,愿得伊人相从,从一而终。<br>微冻,醒来一场梦,一晃无影踪,两眼只朦胧!<br>倚窗问东风,花落谁人梦?</font><br><br><br><font size=’25’ color=’#FFDD00’ face=’楷体_GB2312’>朦胧诗二</font><br><br><font size=’18’ color=’#FFFFFF’ face=’楷体_GB2312’>朦朦胧胧也朦胧,<br>懵懵懂懂亦懵懂。<br>莞笑无语应有意,<br>究竟花落谁人梦。</font><br><br><br><font size=’25’ color=’#FFDD00’ face=’楷体_GB2312’>当年你决定向南而去</font><br><br><font size=’18’ color=’#FFFFFF’ face=’楷体_GB2312’>是否你将要向北远行,<br>那我便放弃向南的决定。<br>你将去哪座茫茫城市,<br>我终究抱着跟随的心。<br>时光这样的飞逝,<br>我们也许没有相聚的日子。<br>我愿珍惜这一份情,<br>直到回忆化成灰烬。<br>愿和我一起走吗?<br>走过会了却心中无际的牵挂。<br>把世上恩怨都抛下,<br>世事无常中渐渐长大。<br>和我一起走好吗?<br>不要让思绪在冷风里挣扎。<br>跟随我吧!<br>你不会害怕,<br>一起营造那温馨的家。</font><br>"; New_Width = 450; New_Height = 280; //这是文本的宽以及初始高度 RollBarFCol = 0x000000; RollBarLCol = 0xFF0000; BGLCol = 0x000000; BGFCol = 0x333333; //滚动条及背景色彩 tempVar0 = Start_x+New_Width; tempVar1 = Start_y+New_Height; //一些临时变量 //—————————————————————————————————————— //现在我们可以开始了,首先需要一个文本: this.createEmptyMovieClip("Text_mc", 1); //我先做了一个名为<Text_mc>的影片剪辑方便存放文本 Text_Width = New_Width-Bar_Width-TeBaD; Text_mc.createTextField("NewText_txt", 0, Start_x, Start_y, Text_Width, New_Height); //创建一个实例名为<NewText_txt>的空白文本 with (Text_mc) { NewText_txt.autoSize = true; //自动调整文本<NewText_txt>的高度 NewText_txt.multiline = true; //设置多行文本 NewText_txt.wordWrap = true; //设置自动换行 NewText_txt.html = true; //采用HTML表示形式 NewText_txt.htmlText = Matter; //内容 var format:TextFormat = new TextFormat(); format.align = "center"; NewText_txt.setTextFormat(format); //居中 } //—————————————————————————————————————— //接下来的就是一个滚动条的制作了: ratio = New_Height/Text_mc._height; if (Text_mc._height>New_Height) { RBHeight = New_Height*ratio; } else { RBHeight = New_Height; } this.createEmptyMovieClip("RollBar_mc", 2); with (RollBar_mc) { beginFill(RollBarFCol, 100); lineStyle(2, RollBarLCol, 70); moveTo(tempVar0-Bar_Width, Start_y); lineTo(tempVar0, Start_y); lineTo(tempVar0, Start_y+RBHeight); lineTo(tempVar0-Bar_Width, Start_y+RBHeight); lineTo(tempVar0-Bar_Width, Start_y); endFill(); } //—————————————————————————————————————— //我们现在还要加一个遮罩层才行: this.createEmptyMovieClip("Mask_mc", 3); with (Mask_mc) { beginFill(0xFF0000, 30); moveTo(Start_x, Start_y); lineTo(Start_x+Text_Width, Start_y); lineTo(Start_x+Text_Width, tempVar1); lineTo(Start_x, tempVar1); lineTo(Start_x, Start_y); endFill(); } Text_mc.setMask(Mask_mc); //—————————————————————————————————————— //然后就是画一个背景了: this.createEmptyMovieClip("BG_mc", 0); with (BG_mc) { Dst1 = 7; //加个Dst变量控制背景边缘与文本的距离,免得背景的边缘紧贴文本 beginFill(BGFCol, 100); lineStyle(3, BGLCol, 30); moveTo(Start_x-Dst1, Start_y-Dst1); lineTo(Start_x-Dst1, tempVar1+Dst1); lineTo(tempVar0+Dst1, tempVar1+Dst1); lineTo(tempVar0+Dst1, Start_y-Dst1); lineTo(Start_x-Dst1, Start_y-Dst1); Dst2 = 2; moveTo(tempVar0-Bar_Width-Dst2, Start_y-Dst2); lineTo(tempVar0+Dst2, Start_y-Dst2); lineTo(tempVar0+Dst2, tempVar1+Dst2); lineTo(tempVar0-Bar_Width-Dst2, tempVar1+Dst2); lineTo(tempVar0-Bar_Width-Dst2, Start_y+Dst2); endFill(); } //—————————————————————————————————————— //最后让滚动条及文本都动起来: RollBar_mc.onPress = function() { this.startDrag(false, 0, 0, 0, New_Height-RBHeight); Move = true; }; RollBar_mc.onMouseUp = function() { this.stopDrag(); Move = false; }; Text_mc.onEnterFrame = function() { if (Move) { TEndY = -RollBar_mc._y/ratio; } this._y -= (this._y-TEndY)/8; }; |
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |