论文部分内容阅读
摘要:Flash中的ActionScrip是一种编程语言,使Flash能够实现更多的功能。该文给出了一种制作通用朗读类课件的构想,并介绍了用Flash中的ActionScrip具体实现的方法, 对多媒体教学课件的制作具有实用价值。
关键词:ActionScrip;影片剪辑;交互性
中图分类号:TP317.4文献标识码:A文章编号:1009-3044(2008)35-2280-03
Building General-reading Courseware Based on Flash
XUE Bin, FANG Da-liang
(1.Chongqing University, Chongqing 524048;2.Zhanjiang Normal College,Zhanjiang 524048, China)
Abstract: ActionScrip of Flash is one kind of programming language, enables Flash to realize more functions. This article gave one kind of manufacture to read aloud a kind of courseware general the conception, and introduced realized the method specifically with in Flash ActionScrip, had the practical value to the multimedia teaching courseware’s manufacture.
Key words: ActionScrip;MovieClip;Interactive
1 引言
在语言教学课件中,经常要用标准的发音朗读字、词和文章,如果字和词采用线性的方式朗读,则课件缺乏交互性,不利于学生快速掌握朗读中的难点。下面就笔者解决这一问题的制作心得介绍如下。
2 制作思路
2.1 字和词的处理
对于字和词的标准发音文件,用声音处理工具将其切割为单个的字或词的发音文件,并存储为序列MP3声音文件。(如:读的词是“恰好、啤酒、簸箕”,将这个声音切割为三个MP3文件,分别保存为syjz0.mp3、syjz1.mp3、 syjz2.mp3。)为了课件的通用性,可将这些字或词写到一个外部的文本文件中,并且字或词之间用“,”隔开,这样就可以用ActionScript载入这些字或词并且动态地放置到按钮式影片中,这样,学习者点击某个字或词时,就可以听到这个字或词的标准发音。
2.2 文章的处理
对于整篇文章的朗读,只需将文章内容写入到一个外部的文本文件中,用ActionScript载入这些文字的同时,播放它的标准发音文件即可。
3 制作过程
3.1 外部文档的制作
在Flash 文件所在的文件夹内创建一新的文件夹,命名为sound,找专业的朗读人员用goldwave录制字、词及文章的声音并分别命名为zi.mp3、ci.mp3、wenzhang.mp3,将这三个文件保存在sound文件夹中。在goldwave打开zi.mp3和ci.mp3文件,选中朗读的第一个字的声音波形,点击Edit菜单下的Copy命令,再点击Edit菜单下的Paste New,将新的声音文件保存为zi0.mp3。重复操作,则制作出zi1.mp3、zi2.mp3、zi3.mp3、zi4.mp3……的序列文件。对于ci.mp3文件也采取相同的操作方法,产生ci1.mp3、ci2.mp3、ci3.mp3、ci4.mp3……的序列文件。
在Flash 文件所在的文件夹内创建一新的文件夹,命名为text,在text中创建一新的文本文件并命名为zi.txt,其内容为用“,”号分割开的与zi.mp3读音顺序相同的字。词采用相同的操作方法产生ci.txt文件,其内容为用“,”号分割开的与ci.mp3读音顺序相同的词。再创建一个新的文本文件,命名为wenzhang.txt,其内容就是文章的内容,外部文本文档的编码格式为Unicode编码。
3.2 按钮式影片的制作
打开flash新建一个flash文档并保存为langdu.fla。在舞台上绘制一个淡蓝色、无边框、34×34的矩形,选中按F8将其转换为影片剪辑,并给此实例取名为btn_mc,双击进入btn_mc的编辑界面,选中矩形按F8将其转换为按钮,并将此按钮实例的alpha值改为15%,将按钮所在图层命名为mcbtnlayer,新建一个图层并命名为zicilayer,在此图层绘制一个32×30的动态文本框,其字体大小为22,颜色为绿色,将可选状态取消,变量名为context。将此文本框放置在按钮的上方。选中帧,在帧动作面板中输入var soundname;语句。选中 按钮,在动作面板中输入:
on (release)
{
stopAllSounds ();
mysound = new Sound();
mysound.loadSound(soundname, true);
}
3.3 时间轴布置
在主时间轴上共分为三个图层, 由上到下依次为ActionLayer、ContextLayer、BtnLayer,ActionLayer用来写帧代码,ContextLayer用来显示朗读的文本,第2步所作的按钮式影片实例btn_mc就放在此层,BtnLayer放置三个按钮,分别命名为zibtn、cibtn及wenzhangbtn,按钮上文字分别为字、词、文章,用于朗读字、词和文章之间的切换。课件共一帧,全部的切换都用ActionScript代码完成。
3.4 编写程序
在ActionLayer图层的帧代码如下:
system.useCodePage = true;//用于显示中文。
var myArr:Array=new Array();//定义数组变量用于存储字、词或文章的内容。
var pathofsound="./sound/zi";
var log=1;
var btn_mcwidth=_root.btn_mc._width;//将按钮式影片的宽度存储在变量中。
_root.wenzhangarea._visible=false;//使文章显示的文本域组件实例不可见。
function loadtext(myArr:Array,numofzici,pathofsound)
{var numofline=Math.round((Stage.width-40)/(btn_mc._width 2));
for(i=0;i {
_root.btn_mc.duplicateMovieClip("btn_mc" i, i);
_root["btn_mc" i].context = myArr[i];
_root["btn_mc" i].soundname = pathofsound [i] ".mp3";
if (i == 0)
{
_root["btn_mc" i]._x = _root._x 45;
continue;
} // end if
if (i % numofline == 0)
{
_root["btn_mc" i]._x = _root._x 45;
_root["btn_mc" i]._y = i / numofline * _root.btn_mc._height _root.btn_mc._y i / numofline * 5;
continue;
} // end if
_root["btn_mc" i]._x = _root["btn_mc" (i - 1)]._x _root.btn_mc._width 2;
_root["btn_mc" i]._y = _root["btn_mc" (i - 1)]._y;
}//end for
_root.btn_mc._visible=false;
}//end of function
/*此函数完成根据字或词的多少复制按钮式影片剪辑,并将对应的序列声音文件和复制的按钮式影片剪辑绑定,并根据舞台的宽度安排复制得到的按钮式影片式剪辑的位置。最后将按钮式影片剪辑设置为不可见。*/
var my_lv:LoadVars = new LoadVars();/*定义加载变量对象的实例,此实例用于加载外部文档。*/
my_lv.onData = function(rw) {
if(_root.log==2){
_root.unloadtext(myArr.length);
myArr=rw.split(",");
var numofzici=myArr.length;
_root.loadtext(myArr,numofzici,_root.pathofsound);
}else{
if(_root.log==3){
_root.unloadtext(myArr.length);
_root.wenzhangarea.text=rw;
}else{
myArr=rw.split(",");
var numofzici=myArr.length;
_root.loadtext(myArr,numofzici,_root.pathofsound);
}}};//end of function
/*此函数完成根据log值判断并完成字、词或文章的加载。*/
function unloadtext(numofsc)
{
for (i = 0; i <= numofsc; i )
{
removeMovieClip ("btn_mc" i);
} // end of for
} // End of the function
/*此函数用于删除复制的按钮式影片剪辑。即:当显示的内容切换时,将前面显示的内容清除掉。*/
function lineplaysound(soundpath)
{
stopAllSounds ();
mysoundall = new Sound();
mysoundall.loadSound(soundpath, true);
} // End of the function
/*此函数用于线性播放字、词或文章的声音。*/
my_lv.load("./text/zi.txt");//初始界面加载字的内容。
var soundpath="./sound/zi.mp3";
lineplaysound(soundpath);
_root.zibtn.enabled = false;
_root.zibtn._alpha = 30;
_root.cibtn.enabled = true;
_root.wenzhangbtn.enabled = true;
stop();
字按钮zibtn上的代码如下:
on(release){
_root.wenzhangarea._visible=false;
_root.btn_mc._visible=true;
_root.btn_mc._width=_root.btn_mcwidth;
_root.pathofsound="./sound/zi";
_root.log=1;
_root.my_lv.load("./text/zi.txt");
_root.soundpath="./sound/zi.mp3";
_root.lineplaysound(soundpath);
_root.zibtn.enabled = false;
_root.zibtn._alpha=30;
_root.cibtn.enabled = true;
_root.cibtn._alpha = 100;
_root.wenzhangbtn.enabled = true;
_root.wenzhangbtn._alpha=100;
}
/*上面的代码实现字的载入,并线性播放所有字的读音,同时使字按钮zibtn不可用,词按钮cibtn和文章按钮wenzhangbtn可用。*/
词按钮cibtn和文章按钮wenzhangbtn上的代码与字按钮zibtn上的代码相似,由于篇幅所限,在这里只作说明。词按钮cibtn上代码:由于词的宽度大于字的宽度,所以要将按钮式影片剪辑的宽度乘2.5;同时使词按钮cibtn不可用,字按钮zibtn和文章按钮wenzhangbtn可用。文章按钮wenzhangbtn上的代码:由于载入文章是用文本域组件实例载入,所以要将文本域组件实例设为可见,而删除与按钮式影片剪辑相关的语句;同时使文章按钮wenzhangbtn不可用,字按钮zibtn和词按钮cibtn可用。
4 结束语
此课件可用于语文、英语、普通话等语言类内容的识字发音教学,在应用时,只需将外部文档的内容和相应的声音更改即可。如果将此课件加以扩展和网络编程工具相结合,则可实现课件内容的动态更新。
关键词:ActionScrip;影片剪辑;交互性
中图分类号:TP317.4文献标识码:A文章编号:1009-3044(2008)35-2280-03
Building General-reading Courseware Based on Flash
XUE Bin, FANG Da-liang
(1.Chongqing University, Chongqing 524048;2.Zhanjiang Normal College,Zhanjiang 524048, China)
Abstract: ActionScrip of Flash is one kind of programming language, enables Flash to realize more functions. This article gave one kind of manufacture to read aloud a kind of courseware general the conception, and introduced realized the method specifically with in Flash ActionScrip, had the practical value to the multimedia teaching courseware’s manufacture.
Key words: ActionScrip;MovieClip;Interactive
1 引言
在语言教学课件中,经常要用标准的发音朗读字、词和文章,如果字和词采用线性的方式朗读,则课件缺乏交互性,不利于学生快速掌握朗读中的难点。下面就笔者解决这一问题的制作心得介绍如下。
2 制作思路
2.1 字和词的处理
对于字和词的标准发音文件,用声音处理工具将其切割为单个的字或词的发音文件,并存储为序列MP3声音文件。(如:读的词是“恰好、啤酒、簸箕”,将这个声音切割为三个MP3文件,分别保存为syjz0.mp3、syjz1.mp3、 syjz2.mp3。)为了课件的通用性,可将这些字或词写到一个外部的文本文件中,并且字或词之间用“,”隔开,这样就可以用ActionScript载入这些字或词并且动态地放置到按钮式影片中,这样,学习者点击某个字或词时,就可以听到这个字或词的标准发音。
2.2 文章的处理
对于整篇文章的朗读,只需将文章内容写入到一个外部的文本文件中,用ActionScript载入这些文字的同时,播放它的标准发音文件即可。
3 制作过程
3.1 外部文档的制作
在Flash 文件所在的文件夹内创建一新的文件夹,命名为sound,找专业的朗读人员用goldwave录制字、词及文章的声音并分别命名为zi.mp3、ci.mp3、wenzhang.mp3,将这三个文件保存在sound文件夹中。在goldwave打开zi.mp3和ci.mp3文件,选中朗读的第一个字的声音波形,点击Edit菜单下的Copy命令,再点击Edit菜单下的Paste New,将新的声音文件保存为zi0.mp3。重复操作,则制作出zi1.mp3、zi2.mp3、zi3.mp3、zi4.mp3……的序列文件。对于ci.mp3文件也采取相同的操作方法,产生ci1.mp3、ci2.mp3、ci3.mp3、ci4.mp3……的序列文件。
在Flash 文件所在的文件夹内创建一新的文件夹,命名为text,在text中创建一新的文本文件并命名为zi.txt,其内容为用“,”号分割开的与zi.mp3读音顺序相同的字。词采用相同的操作方法产生ci.txt文件,其内容为用“,”号分割开的与ci.mp3读音顺序相同的词。再创建一个新的文本文件,命名为wenzhang.txt,其内容就是文章的内容,外部文本文档的编码格式为Unicode编码。
3.2 按钮式影片的制作
打开flash新建一个flash文档并保存为langdu.fla。在舞台上绘制一个淡蓝色、无边框、34×34的矩形,选中按F8将其转换为影片剪辑,并给此实例取名为btn_mc,双击进入btn_mc的编辑界面,选中矩形按F8将其转换为按钮,并将此按钮实例的alpha值改为15%,将按钮所在图层命名为mcbtnlayer,新建一个图层并命名为zicilayer,在此图层绘制一个32×30的动态文本框,其字体大小为22,颜色为绿色,将可选状态取消,变量名为context。将此文本框放置在按钮的上方。选中帧,在帧动作面板中输入var soundname;语句。选中 按钮,在动作面板中输入:
on (release)
{
stopAllSounds ();
mysound = new Sound();
mysound.loadSound(soundname, true);
}
3.3 时间轴布置
在主时间轴上共分为三个图层, 由上到下依次为ActionLayer、ContextLayer、BtnLayer,ActionLayer用来写帧代码,ContextLayer用来显示朗读的文本,第2步所作的按钮式影片实例btn_mc就放在此层,BtnLayer放置三个按钮,分别命名为zibtn、cibtn及wenzhangbtn,按钮上文字分别为字、词、文章,用于朗读字、词和文章之间的切换。课件共一帧,全部的切换都用ActionScript代码完成。
3.4 编写程序
在ActionLayer图层的帧代码如下:
system.useCodePage = true;//用于显示中文。
var myArr:Array=new Array();//定义数组变量用于存储字、词或文章的内容。
var pathofsound="./sound/zi";
var log=1;
var btn_mcwidth=_root.btn_mc._width;//将按钮式影片的宽度存储在变量中。
_root.wenzhangarea._visible=false;//使文章显示的文本域组件实例不可见。
function loadtext(myArr:Array,numofzici,pathofsound)
{var numofline=Math.round((Stage.width-40)/(btn_mc._width 2));
for(i=0;i
_root.btn_mc.duplicateMovieClip("btn_mc" i, i);
_root["btn_mc" i].context = myArr[i];
_root["btn_mc" i].soundname = pathofsound [i] ".mp3";
if (i == 0)
{
_root["btn_mc" i]._x = _root._x 45;
continue;
} // end if
if (i % numofline == 0)
{
_root["btn_mc" i]._x = _root._x 45;
_root["btn_mc" i]._y = i / numofline * _root.btn_mc._height _root.btn_mc._y i / numofline * 5;
continue;
} // end if
_root["btn_mc" i]._x = _root["btn_mc" (i - 1)]._x _root.btn_mc._width 2;
_root["btn_mc" i]._y = _root["btn_mc" (i - 1)]._y;
}//end for
_root.btn_mc._visible=false;
}//end of function
/*此函数完成根据字或词的多少复制按钮式影片剪辑,并将对应的序列声音文件和复制的按钮式影片剪辑绑定,并根据舞台的宽度安排复制得到的按钮式影片式剪辑的位置。最后将按钮式影片剪辑设置为不可见。*/
var my_lv:LoadVars = new LoadVars();/*定义加载变量对象的实例,此实例用于加载外部文档。*/
my_lv.onData = function(rw) {
if(_root.log==2){
_root.unloadtext(myArr.length);
myArr=rw.split(",");
var numofzici=myArr.length;
_root.loadtext(myArr,numofzici,_root.pathofsound);
}else{
if(_root.log==3){
_root.unloadtext(myArr.length);
_root.wenzhangarea.text=rw;
}else{
myArr=rw.split(",");
var numofzici=myArr.length;
_root.loadtext(myArr,numofzici,_root.pathofsound);
}}};//end of function
/*此函数完成根据log值判断并完成字、词或文章的加载。*/
function unloadtext(numofsc)
{
for (i = 0; i <= numofsc; i )
{
removeMovieClip ("btn_mc" i);
} // end of for
} // End of the function
/*此函数用于删除复制的按钮式影片剪辑。即:当显示的内容切换时,将前面显示的内容清除掉。*/
function lineplaysound(soundpath)
{
stopAllSounds ();
mysoundall = new Sound();
mysoundall.loadSound(soundpath, true);
} // End of the function
/*此函数用于线性播放字、词或文章的声音。*/
my_lv.load("./text/zi.txt");//初始界面加载字的内容。
var soundpath="./sound/zi.mp3";
lineplaysound(soundpath);
_root.zibtn.enabled = false;
_root.zibtn._alpha = 30;
_root.cibtn.enabled = true;
_root.wenzhangbtn.enabled = true;
stop();
字按钮zibtn上的代码如下:
on(release){
_root.wenzhangarea._visible=false;
_root.btn_mc._visible=true;
_root.btn_mc._width=_root.btn_mcwidth;
_root.pathofsound="./sound/zi";
_root.log=1;
_root.my_lv.load("./text/zi.txt");
_root.soundpath="./sound/zi.mp3";
_root.lineplaysound(soundpath);
_root.zibtn.enabled = false;
_root.zibtn._alpha=30;
_root.cibtn.enabled = true;
_root.cibtn._alpha = 100;
_root.wenzhangbtn.enabled = true;
_root.wenzhangbtn._alpha=100;
}
/*上面的代码实现字的载入,并线性播放所有字的读音,同时使字按钮zibtn不可用,词按钮cibtn和文章按钮wenzhangbtn可用。*/
词按钮cibtn和文章按钮wenzhangbtn上的代码与字按钮zibtn上的代码相似,由于篇幅所限,在这里只作说明。词按钮cibtn上代码:由于词的宽度大于字的宽度,所以要将按钮式影片剪辑的宽度乘2.5;同时使词按钮cibtn不可用,字按钮zibtn和文章按钮wenzhangbtn可用。文章按钮wenzhangbtn上的代码:由于载入文章是用文本域组件实例载入,所以要将文本域组件实例设为可见,而删除与按钮式影片剪辑相关的语句;同时使文章按钮wenzhangbtn不可用,字按钮zibtn和词按钮cibtn可用。
4 结束语
此课件可用于语文、英语、普通话等语言类内容的识字发音教学,在应用时,只需将外部文档的内容和相应的声音更改即可。如果将此课件加以扩展和网络编程工具相结合,则可实现课件内容的动态更新。