本站版权所有 新丁flash资源网 保留所有权利 未经许可请勿任意转载或复制使用
请使用1024*768分辨率浏览本站以达到浏览新丁flash资源网的最佳视觉效果
新丁flash资源网中所有的解压密码均为:www.qnflash.com
粤ICP备08010396号

打字效果是Flash动画中常用的文字技巧。本例模仿打字机的效果,让字母逐个出现,顺序排列。本例最终效果图如图1-71所示。

【设计要点】
利用动作脚本中的字符串处理函数:Length()字符串函数可返回指定字符串或变量名称的长度;mystring.substr(start,[length])方法返回字符串中的字符,这些字符从start参数所指定的索引开始,直至达到length参数所指定的字符数为止。substr方法不更改由myString指定的字符串,而是返回一个新字符串。
【步骤】
(1) 启动Flash MX 2004,选择菜单栏中的“修改”|“文档”命令,打开”文档属性”对话框,设置动画尺寸大小为550×400px,“帧频”为12,单击“背景颜色”框,然后在弹出的颜色样本中单击黑色样本,如图1-72所示。
(2) 选择“插入”|“新建元件”命令,打开“创建新元件”对话框,在该对话框中输入元件名称ticker1,并选择行为为“影片剪辑”,如图1-73所示。单击“确定”按钮。


(3) 选择“图层
message1 = "news[flash]:%This newsticker does not %set each character in a different keyframe%all characters are stored in one single %variable%Flash MX 2004 required%The .fla is free for everyone%If you use it I would be pleased to be listed on the creditlist$";
textfIEld1 = "";
laenge1 = length(message1);
counted1 = -1;
done = false;
(4) 右击“图层

(5) 单击“图层
(6) 右击“图层counted1 = Number(counted1)+1;
play();
temp_stuff = message.substr( counted1, 1);
trace(temp_stuff);
trace(counted1);
if (not (temp_stuff eq "$")) {
if (temp_stuff eq "%") {
temp_stuff = newline add "> "; }
textfIEld1 = textfIEld1 + temp_stuff;
gotoAndPlay(4);
}
else {
trace("$ detected!!");
done = true;
}
if (Number(done) == Number(false)) {
gotoAndPlay(4);}
else {
gotoAndPlay(7);
}
(7) 右击图层的第7帧,在弹出的快捷菜单中选择“插入关键帧”命令。单击舞台上方的

(8) 按Ctrl+Enter键显示效果,按Ctrl+W键恢复编辑状态。
【注意事项】
注意mystring.substr(start,[length])函数中指示mystring中用于创建子字符串的第一个字符位置的start参数应该从整数0开始,所以先将count1的初值置设定为-1。