毕业论文 论文提纲 论文写作 公文范例 教育论文 教育学论文 师范教育 学术论文     论文指导*
                     
 
   
   
   
   
           
 

当前位置:课件115学培吧(kj115.com)→flash网侠教程(助你成为顶尖课件高手)→系列文章

 
 
标题:flash影片web播放控制器制作祥解
 
展示台

文章来源 作者:admin 密码:admin 整理:湖北金鹰

◇网侠教程栏目简介
    提供FLASH侠客教程和网页制作侠客教程,高手进阶教程。
    浏览过这些资源的还浏览过经典教程图文教程游戏开发教程等相关资源。

---------------

湖北金鹰课件吧

论文相关服务
 

 

在闪吧看到了这个flash播放器,想下载其源码下来研究已供自己使用,没想到闪吧已做禁止下载功能。费了几天的网上搜索,除了几篇相关资料外,没有源码下载,更没有实例讲解。受不住诱惑,只好自己参考资料亲手写了。这个flash影片播放控制器时用了闪吧的播放界面,程序代码完全亲手写上。
首先我们看看flash播放控制器的界面(很简单的Html代码,不过不是自己源创的) 定义样式:
<style>
body,td,button{font:normal 12px Tahoma;color:#333333;text-align:center}
.drag{position:relative;cursor:hand}
button{border:1px solid #333333;background:#EEEEEE;margin:2px;font-family:Webdings;height:20px}
div{cursor:default}
#menu{margin:3;line-height:20px;border:1px solid #dedede;background:#FFFFFF;display:none;position:absolute}
#menu a:link,a:visited{border:1px solid #FFFFFF;background:#FFFFFF;text-decoration:none;display:block;padding:0 3;margin:1;color:#333333;cursor:default;text-align:left;text-indent:15px}
#menu a:hover{background:#dedede;border-color:#666666;color:#000000}
#ctlButtons IMG{behavior:url(rollover.htc)}
</style>
引用驱动程序:
<script src="play.js"></script>
以下是flash影片播放和控制界面代码:
<div oncontextmenu="return false" onselectstart="return false">
<div style="padding:0">
<table border="0" cellpadding="0" cellspacing="1" bgcolor="#000000"><tr><td>
<object id="movie" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase= "http://download.macromedia.com/pub/ shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="550" height="400" align="middle">
<param name="movie" value="about:blank" />
<param name="quality" value="high" />
</object>
</td></tr></table>
<table style="width:550px;height:35px;vertical-align:bottom" cellspacing="0" cellpadding="0" border="0">
<tr>
<td style="">
<table style="border:0px solid #333333;width:90%;" cellpadding="1" cellspacing="0">
<tr>
<td style="text-align:left;vertical-align:left;background:url(bg.gif);height:8px" onMouseDown="Jump(total*event.offsetX/4210)">
<div id="bar" style="width:0%;font:3px;height:3px;background:#00FF44"></div>
</td>
<tr>
</table>
</td>
<td style="text-align:right;width:50px;font:11px Tahoma" id="frameCount"></td>
</tr>
</table>
<span id="ctlButtons">
<img onClick="Rewind();" title="跳至第一帧" text="9" src="http://www.webjx.com/htmldata/sort/images/button/dd1.gif" hoverSrc="http://www.webjx.com/htmldata/sort/images/button/hh1.gif">
<img onClick="Back();" title="快退" text="7" src="http://www.webjx.com/htmldata/sort/images/button/dd2.gif" hoverSrc="http://www.webjx.com/htmldata/sort/images/button/hh2.gif">
<img onClick="Play();" title="播放" text="4" src="http://www.webjx.com/htmldata/sort/images/button/dd3.gif" hoverSrc="http://www.webjx.com/htmldata/sort/images/button/hh3.gif">
<img onClick="Pause();" title="暂停" text=";" src="http://www.webjx.com/htmldata/sort/images/button/dd4.gif" hoverSrc="http://www.webjx.com/htmldata/sort/images/button/hh4.gif">
<img onClick="Stop();" title="停止" text="<" src="http://www.webjx.com/htmldata/sort/images/button/dd5.gif" hoverSrc="http://www.webjx.com/htmldata/sort/images/button/hh5.gif">
<img onClick="Forward();" title="快进" text="8"
<img onClick="Forward();" title="快进" text="8"
//以下是滚动条图片拖动程序
var dragapproved=false;
var z,x,y
//移动函数
function move(){
if (event.button==1&&dragapproved){
y=temp1+event.clientX-x;
//以下是控制移动的范围
if(y<0)
y=0;
if(y>420)
y=420;
z.style.pixelLeft=y
movie.GotoFrame(y/420*total);//移动到某一位置,flash影片播放到某个位置
return false
}
}
//获得拖动前初始数据的函数
function drags(){
if (!document.all)
return
if (event.srcElement.className=="drag"){
dragapproved=true
z=event.srcElement
temp1=z.style.pixelLeft
x=event.clientX
document.onmousemove=move
}
}
//动态显示播放影片的当前桢/总桢数
function showcount(){
frame_number=movie.CurrentFrame();
frame_number++;
frameCount.innerText=frame_number+"/"+movie.TotalFrames;
element.style.pixelLeft=420*(frame_number/movie.TotalFrames);//滚动条图片随之到相应的位置
if(frame_number==movie.TotalFrames)
clearTimeout(tn_ID);
else
var tn_ID=setTimeout(''''''''showcount();'''''''',1000);
}
//使影片返回第一帧
function Rewind(){
if(movie.IsPlaying()){
Pause();
}
movie.Rewind();
element.style.pixelLeft=0;
frameCount.innerText="1/"+total;
}
//播放影片
function Play(){
movie.Play();
showcount();
}
//暂停播放
function Pause(){
movie.StopPlay();
}
//跳至最末帧
function GoToEnd(){
if(movie.IsPlaying())
Pause();
movie.GotoFrame(total);
element.style.pixelLeft=420;
frameCount.innerText=total+"/"+total;
}
//快退影片
function Back()
{
if(movie.IsPlaying())
Pause();
frame_number=frame_number-50;
movie.GotoFrame(frame_number);
Play();
}
//快进影片
function Forward()

if(movie.IsPlaying())
Pause();
frame_number=frame_number+50;
movie.GotoFrame(frame_number);
Play();
}
//重新播放影片
function Replay(){
if(movie.IsPlaying()){
Pause();
movie.Rewind();
Play();
}
else
{
movie.Rewind();
Play();
}
}
//停止播放影片返回到第一桢
function Stop(){
if(movie.IsPlaying()){
Pause();
movie.Rewind();
}
else
{
movie.Rewind();
}
}
//显示影片载入进度,完全载入后控制按钮可用
function jindu(){
var in_ID;
bar.style.width=Math.round(movie.PercentLoaded())+"%";
frameCount.innerText=Math.round(movie.PercentLoaded())+"%";
if(movie.PercentLoaded() == 100){
ctlButtons.document.all.tags(''''''''IMG'''''''')[0].disabled=false;
ctlButtons.document.all.tags(''''''''IMG'''''''')[1].disabled=false;
ctlButtons.document.all.tags(''''''''IMG'''''''')[2].disabled=false;
ctlButtons.document.all.tags(''''''''IMG'''''''')[3].disabled=false;
ctlButtons.document.all.tags(''''''''IMG'''''''')[4].disabled=false;
ctlButtons.document.all.tags(''''''''IMG'''''''')[5].disabled=false;
ctlButtons.document.all.tags(''''''''IMG'''''''')[6].disabled=false;
ctlButtons.document.all.tags(''''''''IMG'''''''')[7].disabled=false;
ctlButtons.document.all.tags(''''''''IMG'''''''')[8].disabled=false;
total=movie.TotalFrames;
frame_number++;
frameCount.innerText=frame_number+"/"+total;
bar.style.background="";
//bar.style.width="0%"
bar.innerHTML=''''''''<img src="http://www.webjx.com/htmldata/sort/images/button/posbar1.gif" style="cursor:hand;border:0;" id="element" class="drag" OnMouseOver="fnOnMouseOver()" OnMouseOut="fnOnMouseOut()">'''''''';
document.onmousedown=drags
document.onmouseup=new Function("dragapproved=false;Play()")
showcount();
clearTimeout(in_ID);
}
else
in_ID=setTimeout("jindu();",1000);
}
//开始载入flash影片,载入过程中,播放控制按钮不可用
function loadSWF(fsrc,fwidth,fheight){
movie.LoadMovie(0, fsrc);
movie.width=fwidth;
movie.height=fheight;
ctlButtons.document.all.tags(''''''''IMG'''''''')[0].disabled=true;
ctlButtons.document.all.tags(''''''''IMG'''''''')[1].disabled=true;
ctlButtons.document.all.tags(''''''''IMG'''''''')[2].disabled=true;
ctlButtons.document.all.tags(''''''''IMG'''''''')[3].disabled=true;
ctlButtons.document.all.tags(''''''''IMG'''''''')[4].disabled=true;
ctlButtons.document.all.tags(''''''''IMG'''''''')[5].disabled=true;
ctlButtons.document.all.tags(''''''''IMG'''''''')[6].disabled=true;
ctlButtons.document.all.tags(''''''''IMG'''''''')[7].disabled=true;
ctlButtons.document.all.tags(''''''''IMG'''''''')[8].disabled=true;
frame_number=movie.CurrentFrame();
jindu();
}
//显示层函数
function showMenu(menu){
menu.style.display=''''''''block'''''''';
}
//鼠标点击滚动条上的位置,影片相应播放到那个位置
function Jump(fnume){
if(movie.IsPlaying()){
Pause();
movie.GotoFrame(fnume);
Play();
}
else
{
movie.GotoFrame(fnume);
Play();
}
}
//以下两个函数是图片切换函数
function fnOnMouseOver(){
element.src = "images/button/posbar.gif";
}
function fnOnMouseOut(){
element.src = "images/button/posbar1.gif";
}
以上代码,我们仔细研究后会发现其实很简单,不过却费了我很大精力。欢迎大家继续在此基础上改进,增添新的功能。
附可控制Flash Player的Javascript方法。 一览表:
Play() ---------------------------------------- 播放动画
StopPlay()------------------------------------停止动画
IsPlaying()----------------------------------- 动画是否正在播放
GotoFrame(frame_number)---------------- 跳转到某帧
TotalFrames()------------------------------- 获取动画总帧数
CurrentFrame()------------------------------回传当前动画所在帧数-1
Rewind()-------------------------------------使动画返回第一帧
SetZoomRect(left,top,right,buttom)-------放大指定区域
Zoom(percent)------------------------------改变动画大小
Pan(x_position,y_position,unit)------------使动画在x,y方向上平移
PercentLoaded()----------------------------返回动画被载入的百分比
LoadMovie(level_number,path)----------- 加载动画
TGotoFrame(movie_clip,frame_number)- movie_clip跳转到指定帧数
TGotoLabel(movie_clip,label_name)------ movie_clip跳转到指定标签
TCurrentFrame(movie_clip)--------------- 回传movie_clip当前帧-1
TCurrentLabel(movie_clip)-----------------回传movie_clip当前标签
TPlay(movie_clip)---------------------------播放movie_clip
TStopPlay(movie_clip)----------------------停止movie_clip的播放
GetVariable(variable_name)-----------------获取变量
SetVariable(variable_name,value)-----------变量赋值
TCallFrame(movie_clip,frame_number)---call指定帧上的action
TCallLabel(movie_clip,label)----------------call指定标签上的action
TGetProperty(movie_clip,property)--------获取movie_clip的指定属性
TSetProperty(movie_clip,property,number)-设置movie_clip的指定属性
以上代码,我们仔细研究后会发现其实很简单,不过却费了我很大精力。欢迎大家继续在此基础上改进,增添新的功能。

 

 
课件115学培吧(湖北金鹰)欢迎您!永久免费服务网址:http://www.kj115.com
   
 

学员众多的FLASH课件学习基地,成万免费FLASH课件制作教程在线学习,还有免费内容课件教程、视频教程、课件技巧、课件探讨、课件欣赏、课件展示、实用教程、课件界面、课件脚本、课件游戏、课件下载、课件封面、课文内容图片、课文人物图片库、课件素材、图片素材、声音素材、动物素材、背景图片、背景资料、背景边框、课件顶栏图片素材、Dreamweaver教程、Dreamweaver网页课件教程、软件下载。承接学习和培训,承接课件订制,课件修改等所有课件相关服务。
本站主要业务:┃flash课件制作视频教程培训┃承接全国竞赛flash课件┃论文代写代发┃代办课件国家级获奖证书┃
联系:QQ:444860709 手机:13339817386


 
 

业务办理
鄂ICP备08005724号