最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
AS打字代码
时间:2022-07-02 17:05:03 编辑:袖梨 来源:一聚教程网
纯AS打字超出边框向上滚动且自动添加滚动条。
[过程]
在第一帧写如下代码即可:
fscommand("fullscreen", "false");
fscommand("allowscale", "false");
fscommand("showmenu", "false");
//var my_sound:Sound = new Sound(this);
//画外框
this.createEmptyMovieClip("kuang_mc", 5);
kuang_mc.lineStyle(2, 0xC9C08F);
kuang_mc.moveTo(1, 1);
kuang_mc.lineTo(415, 1);
kuang_mc.lineTo(415, 299);
kuang_mc.lineTo(1, 299);
kuang_mc.lineTo(1, 1);
//画背景
this.createEmptyMovieClip("beijing_mc", 0);
beijing_mc.beginFill(0xECE9DB);
beijing_mc.moveTo(0, 0);
beijing_mc.lineTo(416, 0);
beijing_mc.lineTo(416, 300);
beijing_mc.lineTo(0, 300);
beijing_mc.lineTo(0, 0);
beijing_mc.endFill();
//画遮罩
this.createEmptyMovieClip("mask_mc", 1);
mask_mc.beginFill(0xFFFFFF);
mask_mc.moveTo(0, 0);
mask_mc.lineTo(396, 0);
mask_mc.lineTo(396, 300);
mask_mc.lineTo(0, 300);
mask_mc.lineTo(0, 0);
mask_mc.endFill();
mask_mc._alpha = 0;
//画滚动条背景
mask_mc.duplicateMovieClip("gundongtiaobj_mc", 2);
gundongtiaobj_mc._alpha = 100;
gundongtiaobj_mc._x = mask_mc._x+mask_mc._width;
gundongtiaobj_mc._width = 20;
//画滚动条
gundongtiaobj_mc.duplicateMovieClip("_btn", 3);
gundongtiao_color = new Color(_btn);
_btn._x = gundongtiaobj_mc._x;
gundongtiao_color.setRGB(0xC0D2FC);
//创建打字影片剪辑
this.createEmptyMovieClip("_mc", 4);
_mc._x = mask_mc._x;
_mc._y = mask_mc._y;
_mc.setMask(mask_mc);
//申明的一些变量
var i:Number = 0;
var my_fmt:TextFormat = new TextFormat();
var my_str:String = "动画原创作者——刘常(琴者qinz)"+newline+"再别康桥——徐志摩"+newline+"轻轻的我走了,正如我轻轻的来;"+newline+"我轻轻的招手,作别西天的云彩。"+newline+"那河畔的金柳,是夕阳中的新娘;"+newline+"波光里的艳影,在我的心头荡漾。"+newline+"软泥上的青荇,油油的在水底招摇;"+newline+"在康河的柔波里,我甘心做一条水草!"+newline+"那榆荫下的一潭,不是清泉,"+newline+"是天上虹揉碎在浮藻间,沉淀着彩虹似的梦。"+newline+"寻梦?撑一支长篙,向青草更青处漫溯,"+newline+"满载一船星辉,在星辉斑斓里放歌。"+newline+"但我不能放歌,悄悄是别离的笙箫;"+newline+"夏虫也为我沉默,沉默是今晚的康桥。"+newline+"悄悄的我走了,正如我悄悄的来;"+newline+"我挥一挥衣袖,不带走一片云彩。";
//创建动态文本
_mc.createTextField("my_txt", 1, 50, 20, 0, 0);
//控制文本字段的自动大小调整和左对齐
_mc.my_txt.autoSize = true;
_mc.my_txt.selectable = false;
//设置文本行距
my_fmt.leading = 20;
//设置文本的颜色
my_fmt.color = 0x000000;
//动态文本应用新文本格式
_mc.my_txt.setNewTextFormat(my_fmt);
//文字背景,防止最后几行显示
_mc.createEmptyMovieClip("wzbj_mc", 2);
_mc.wzbj_mc.beginFill(0x00FF00, 0);
_mc.wzbj_mc.moveTo(0, 0);
_mc.wzbj_mc.lineTo(400, 0);
_mc.wzbj_mc.lineTo(400, 300);
_mc.wzbj_mc.lineTo(0, 300);
_mc.wzbj_mc.lineTo(0, 0);
_mc.wzbj_mc.endFill();
_mc.onEnterFrame = function() {
this.wzbj_mc._height = this.my_txt._height+35;
this.wzbj_mc._y = this.my_txt._y-20;
//如果变量i不大于my_str的字符数
if (i<=length(my_str)) {
_btn.enabled = false;
//动态文本显示my_str的字符(从第一个字符开始,长度为i)
this.my_txt.text = my_str.substr(0, i)+"_";
//变量递增1
i++;
if ((this.my_txt._y+this.my_txt._height)>mask_mc._height) {
this.wzbj_mc._y = this.my_txt._y -= 35;
} else {
this.my_txt._y -= 0;
}
}
//如果变量i大于my_str的字符数
if (i>length(my_str)) {
// my_sound.stop();
_btn.enabled = true;
this.my_txt.text = my_str;
//停止 setInterval() 调用
delete this.onEnterFrame;
delete mask_mc.onEnterFrame;
}
};
mask_mc.onEnterFrame = function() {
//申明影片剪辑滚动距离变量及按钮和按钮背景影片剪辑的可见性设置
var ypgdjl:Number = _mc._height-mask_mc._height;
if (ypgdjl<=0) {
_btn._visible = 0;
} else {
_btn._visible = 1;
}
_btn._height = int(mask_mc._height*((_mc._height-ypgdjl)/_mc._height));
_btn._y = mask_mc._height-_btn._height+mask_mc._y;
var btntdjl:Number = mask_mc._height-_btn._height;
//按钮按下开始拖动并设置影片剪辑的坐标
_btn.onPress = function() {
startDrag(this, false, mask_mc._width+mask_mc._x, mask_mc._y, mask_mc._width+mask_mc._x, btntdjl+mask_mc._y);
_mc.onEnterFrame = function() {
_mc._y = -(int((_btn._y/btntdjl)*ypgdjl))+ypgdjl;
};
};
_btn.onRelease = _btn.onReleaseOutside=function () {
stopDrag();
};
};
fscommand("allowscale", "false");
fscommand("showmenu", "false");
//var my_sound:Sound = new Sound(this);
//画外框
this.createEmptyMovieClip("kuang_mc", 5);
kuang_mc.lineStyle(2, 0xC9C08F);
kuang_mc.moveTo(1, 1);
kuang_mc.lineTo(415, 1);
kuang_mc.lineTo(415, 299);
kuang_mc.lineTo(1, 299);
kuang_mc.lineTo(1, 1);
//画背景
this.createEmptyMovieClip("beijing_mc", 0);
beijing_mc.beginFill(0xECE9DB);
beijing_mc.moveTo(0, 0);
beijing_mc.lineTo(416, 0);
beijing_mc.lineTo(416, 300);
beijing_mc.lineTo(0, 300);
beijing_mc.lineTo(0, 0);
beijing_mc.endFill();
//画遮罩
this.createEmptyMovieClip("mask_mc", 1);
mask_mc.beginFill(0xFFFFFF);
mask_mc.moveTo(0, 0);
mask_mc.lineTo(396, 0);
mask_mc.lineTo(396, 300);
mask_mc.lineTo(0, 300);
mask_mc.lineTo(0, 0);
mask_mc.endFill();
mask_mc._alpha = 0;
//画滚动条背景
mask_mc.duplicateMovieClip("gundongtiaobj_mc", 2);
gundongtiaobj_mc._alpha = 100;
gundongtiaobj_mc._x = mask_mc._x+mask_mc._width;
gundongtiaobj_mc._width = 20;
//画滚动条
gundongtiaobj_mc.duplicateMovieClip("_btn", 3);
gundongtiao_color = new Color(_btn);
_btn._x = gundongtiaobj_mc._x;
gundongtiao_color.setRGB(0xC0D2FC);
//创建打字影片剪辑
this.createEmptyMovieClip("_mc", 4);
_mc._x = mask_mc._x;
_mc._y = mask_mc._y;
_mc.setMask(mask_mc);
//申明的一些变量
var i:Number = 0;
var my_fmt:TextFormat = new TextFormat();
var my_str:String = "动画原创作者——刘常(琴者qinz)"+newline+"再别康桥——徐志摩"+newline+"轻轻的我走了,正如我轻轻的来;"+newline+"我轻轻的招手,作别西天的云彩。"+newline+"那河畔的金柳,是夕阳中的新娘;"+newline+"波光里的艳影,在我的心头荡漾。"+newline+"软泥上的青荇,油油的在水底招摇;"+newline+"在康河的柔波里,我甘心做一条水草!"+newline+"那榆荫下的一潭,不是清泉,"+newline+"是天上虹揉碎在浮藻间,沉淀着彩虹似的梦。"+newline+"寻梦?撑一支长篙,向青草更青处漫溯,"+newline+"满载一船星辉,在星辉斑斓里放歌。"+newline+"但我不能放歌,悄悄是别离的笙箫;"+newline+"夏虫也为我沉默,沉默是今晚的康桥。"+newline+"悄悄的我走了,正如我悄悄的来;"+newline+"我挥一挥衣袖,不带走一片云彩。";
//创建动态文本
_mc.createTextField("my_txt", 1, 50, 20, 0, 0);
//控制文本字段的自动大小调整和左对齐
_mc.my_txt.autoSize = true;
_mc.my_txt.selectable = false;
//设置文本行距
my_fmt.leading = 20;
//设置文本的颜色
my_fmt.color = 0x000000;
//动态文本应用新文本格式
_mc.my_txt.setNewTextFormat(my_fmt);
//文字背景,防止最后几行显示
_mc.createEmptyMovieClip("wzbj_mc", 2);
_mc.wzbj_mc.beginFill(0x00FF00, 0);
_mc.wzbj_mc.moveTo(0, 0);
_mc.wzbj_mc.lineTo(400, 0);
_mc.wzbj_mc.lineTo(400, 300);
_mc.wzbj_mc.lineTo(0, 300);
_mc.wzbj_mc.lineTo(0, 0);
_mc.wzbj_mc.endFill();
_mc.onEnterFrame = function() {
this.wzbj_mc._height = this.my_txt._height+35;
this.wzbj_mc._y = this.my_txt._y-20;
//如果变量i不大于my_str的字符数
if (i<=length(my_str)) {
_btn.enabled = false;
//动态文本显示my_str的字符(从第一个字符开始,长度为i)
this.my_txt.text = my_str.substr(0, i)+"_";
//变量递增1
i++;
if ((this.my_txt._y+this.my_txt._height)>mask_mc._height) {
this.wzbj_mc._y = this.my_txt._y -= 35;
} else {
this.my_txt._y -= 0;
}
}
//如果变量i大于my_str的字符数
if (i>length(my_str)) {
// my_sound.stop();
_btn.enabled = true;
this.my_txt.text = my_str;
//停止 setInterval() 调用
delete this.onEnterFrame;
delete mask_mc.onEnterFrame;
}
};
mask_mc.onEnterFrame = function() {
//申明影片剪辑滚动距离变量及按钮和按钮背景影片剪辑的可见性设置
var ypgdjl:Number = _mc._height-mask_mc._height;
if (ypgdjl<=0) {
_btn._visible = 0;
} else {
_btn._visible = 1;
}
_btn._height = int(mask_mc._height*((_mc._height-ypgdjl)/_mc._height));
_btn._y = mask_mc._height-_btn._height+mask_mc._y;
var btntdjl:Number = mask_mc._height-_btn._height;
//按钮按下开始拖动并设置影片剪辑的坐标
_btn.onPress = function() {
startDrag(this, false, mask_mc._width+mask_mc._x, mask_mc._y, mask_mc._width+mask_mc._x, btntdjl+mask_mc._y);
_mc.onEnterFrame = function() {
_mc._y = -(int((_btn._y/btntdjl)*ypgdjl))+ypgdjl;
};
};
_btn.onRelease = _btn.onReleaseOutside=function () {
stopDrag();
};
};
相关文章
- 《无限暖暖》天星之羽获得位置介绍 12-20
- 《流放之路2》重铸台解锁方法介绍 12-20
- 《无限暖暖》瞄准那个亮亮的成就怎么做 12-20
- 《无限暖暖》魔气怪终结者完成方法 12-20
- 《无限暖暖》曙光毛团获得位置介绍 12-20
- 《无限暖暖》日光果获得位置介绍 12-20