读书人

容易的flash播放进度控制条

发布时间: 2012-11-04 10:42:42 作者: rapoo

简单的flash播放进度控制条

?实际运用时,将下列源文件中的Control_progress实例copy到需要的文件中去就行了。Control_progress的宽度与高度随便你调整。[1b]特别说明:[/1b]本实例中用了三个as动态文本,其实你也可以直接创建,不必用as书写。这样代码会少很多了。观看效果:
1、新建一个电影元件,名为move_mc,它是作为显示和控制进度的移动小块,宽度*高度=10*10,透明度为0(目的是能感应鼠标),另画一个红色的小十字作为移动时的指针。
2、另新建一个电影元件,名为Control_progress。
2.1在其第一层画一个宽度*高度=400*10的作为背景的色条;
2.2在其第二图层,放置一个电影实例宽度*高度=398*8,颜色是绿色,位置是_x=1;_y=1;实例名是bar_mc
2.3拖放上述第一步做的那个move_mc放在其第三图层上,命名为move_mc。
2.4、另建第四个图层,作为as层,其上的代码如下:
this.createTextField("currentframe_txt",?0,?0,?-2,?200,?12);//显示当前帧数
this.createTextField("totalframe_txt",?1,?200,?-2,?200,?12);//显示总帧数
this.createTextField("prompt_txt",?2,?0,?-16,?50,?12);//拖动提示文本
currentframe_txt.selectable?=?false;//文本不可选
totalframe_txt.selectable?=?false;
prompt_txt.selectable?=?false;
//文本格式
var?format0:TextFormat?=?new?TextFormat();
format0.align?=?"left";
format0.font?=?"Tahoma";
format0.size?=?8;
format0.color?=?0x000000;
currentframe_txt.autoSize?=?true;
var?format1:TextFormat?=?new?TextFormat();
format1.align?=?"right";
format1.font?=?"Tahoma";
format1.size?=?8;
format1.color?=?0x000000;
totalframe_txt.autoSize?=?true;
totalframe_txt.wordWrap?=?true;
totalframe_txt.text?=?"total:?"+_root._totalframes;
totalframe_txt.setTextFormat(format1);
prompt_txt.autoSize?=?true;
prompt_txt.borderColor?=?0xFFFFFF;
prompt_txt.backgroundColor?=?0xD9D9D9;
var?format2:TextFormat?=?new?TextFormat();
format2.align?=?"left";
format2.font?=?"Tahoma";
format2.size?=?8;
format2.color?=?0x000000;
//....................................................................
var?switchB:Boolean?=?true;//开关布尔值
onEnterFrame?=?function?()?{
?var?l:Number?=?_root._currentframe;?//当前帧数
?var?t:Number?=?_root._totalframes;?//文件总帧数
?currentframe_txt.text?=?"current:?"+l;//文本显示当前帧数
?currentframe_txt.setTextFormat(format0);
?if?(switchB)?{
??move_mc._x?=?(l*390/t);//红色十字的移动位置
?}?else?{
??prompt_txt._x?=?move_mc._x;?//拖动提示文本
?}
?var?i:Number?=?Math.round(move_mc._x*Number(t/390));//当前帧数
?var?per:Number?=?Math.round((l/t)*100);//当前百分比
?bar_mc._xscale?=?per;//绿色移动条长度
?_root.gotoAndPlay(i);
?updateAfterEvent();
};
move_mc.onRollOver?=?function()?{
本文转自:http://www.5uflash.com/flashjiaocheng/Flash-loadingjiaocheng/2071.html

读书人网 >Flash

热点推荐