使用Flash循环播放图片的Demo

点击下载关键文件放程序根目录

静态实现

ContractedBlock.gif ExpandedBlockStart.gif Code
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ImageDemo._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    
<title>无标题页</title>
    
<script type="text/javascript" language="javascript">
    
function ImgTran()
     {
         
var imgArr=[{imgUrl:'http://www.gd.ehome.cn/EhomeClub/images/TImage1.jpg',imgLink:escape('http://www.gd.ct10000.com/gz/zt/200803S/ay_wlan_wxty.htm'),imgtext:'链接1'},
                     {imgUrl:
'http://www.gd.ehome.cn/EhomeClub/images/TImage2.jpg',imgLink:escape('http://www.gd.ct10000.com/gz/zt/200803S/ehome.htm'),imgtext:'链接2'},
                     {imgUrl:
'http://www.gd.ehome.cn/EhomeClub/images/TImage3.jpg',imgLink:escape('http://www.gd.ct10000.com/gz/zt/200803S/sdy.htm'),imgtext:'链接3'},
                     {imgUrl:
'http://www.gd.ehome.cn/EhomeClub/images/TImage4.jpg',imgLink:escape('http://onehome.gd.vnet.cn/htmlpages/huapi/index.htm'),imgtext:'链接4'},
                     {imgUrl:
'http://www.gd.ehome.cn/EhomeClub/images/TImage5.jpg',imgLink:escape('http://www.gd.ct10000.com/gz/zt/200803S/hero1.htm'),imgtext:'链接5'},
                     {imgUrl:
'http://www.gd.ehome.cn/EhomeClub/images/TImage6.jpg',imgLink:escape('http://www.gznet.com/telecom/zt/ehome0815/index.html'),imgtext:'链接6'},
                     {imgUrl:
'http://www.gd.ehome.cn/EhomeClub/images/TImage7.jpg',imgLink:escape('http://www.gd.ct10000.com/gz/zt/200803S/jsyq.htm'),imgtext:'链接7'}
                    ];
               
var jscode="";
              
var focus_width=578 ;
              
var focus_height=200  ;
              
var text_height=20;
              
var swf_height = focus_height+text_height ;
              
var pics="";
              
var links="";
              
var texts="";
              
              
for(var i=0;i<imgArr.length;i++)
              {
                  
if(i==0)
                  {
                      pics
+=imgArr[i].imgUrl;
                      links
+=imgArr[i].imgLink;
                      texts
+= imgArr[i].imgtext;
                  }
                  
else
                  {
                      pics
+="|"+imgArr[i].imgUrl;
                      links
+="|"+imgArr[i].imgLink;
                      texts
+="|"+ imgArr[i].imgtext;
                  }
             }
             jscode
+='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">';
             jscode
+='<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="focus.swf"><param name="quality" value="high"><param name="bgcolor" value="#F0F0F0">';
             jscode
+='<param name="menu" value="false"><param name=wmode value="opaque">';
             jscode
+='<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">';
             jscode
+='<embed src="pixviewer.swf" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" menu="false" bgcolor="#F0F0F0" quality="high" width="'+ focus_width +'" height="'+ focus_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';  
             jscode
+='</object>'
             document.getElementById(
"flashImg").innerHTML=jscode;             
     }                
    
</script>

</head>
<body>
    
<form id="form1" runat="server">
        
<div id="flashImg" style="text-align:center">
            
<!--************动态图片**************--> 
        
</div>
        
<script  type="text/javascript">
                ImgTran();
        
</script>
    
</form>
</body>
</html>

 

动态实现

ContractedBlock.gif ExpandedBlockStart.gif Code
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default2.aspx.cs" Inherits="ImageDemo.Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    
<title>无标题页</title>
    
<script type="text/javascript" language="javascript">
    
function ImgTran()
     {
               
var jscode="";
              
var focus_width=578 ;
              
var focus_height=200  ;
              
var text_height=20;
              
var swf_height = focus_height+text_height ;
              
var pics="";
              
var links="";
              
var texts="";
              
              
for(var i=0;i<imgArr.length;i++)
              {
                  
if(i==0)
                  {
                      pics
+=imgArr[i].imgUrl;
                      links
+=imgArr[i].imgLink;
                      texts
+= imgArr[i].imgtext;
                  }
                  
else
                  {
                      pics
+="|"+imgArr[i].imgUrl;
                      links
+="|"+imgArr[i].imgLink;
                      texts
+="|"+ imgArr[i].imgtext;
                  }
             }
             jscode
+='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">';
             jscode
+='<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="focus.swf"><param name="quality" value="high"><param name="bgcolor" value="#F0F0F0">';
             jscode
+='<param name="menu" value="false"><param name=wmode value="opaque">';
             jscode
+='<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">';
             jscode
+='<embed src="pixviewer.swf" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" menu="false" bgcolor="#F0F0F0" quality="high" width="'+ focus_width +'" height="'+ focus_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';  
             jscode
+='</object>'
             document.getElementById(
"flashImg").innerHTML=jscode;  
     }                
    
</script>

</head>
<body>
    
<form id="form1" runat="server">
        
<div id="flashImg" style="text-align:center">
            
<!--************动态图片**************--> 
        
</div>
    
</form>
</body>
</html>

 

ContractedBlock.gif ExpandedBlockStart.gif Code
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;

namespace ImageDemo
{
    
public partial class Default2 : System.Web.UI.Page
    {
        
protected void Page_Load(object sender, EventArgs e)
        {
            CreatePhotoTran();
            ScriptManager.RegisterStartupScript(
this.Page, this.GetType(), "createPhotoJson""ImgTran();"true);
        }
        
private void CreatePhotoTran()
        {
            StringBuilder photoJson 
= new StringBuilder();
            photoJson.Append(
"imgArr = [");
            
            photoJson.Append(
"{imgUrl:'http://www.gd.ehome.cn/EhomeClub/images/TImage1.jpg',imgLink:escape('http://www.gd.ct10000.com/gz/zt/200803S/ay_wlan_wxty.htm'),imgtext:'链接1'},");
            photoJson.Append(
"{imgUrl:'http://www.gd.ehome.cn/EhomeClub/images/TImage2.jpg',imgLink:escape('http://www.gd.ct10000.com/gz/zt/200803S/ehome.htm'),imgtext:'链接2'},");
            photoJson.Append(
"{imgUrl:'http://www.gd.ehome.cn/EhomeClub/images/TImage3.jpg',imgLink:escape('http://www.gd.ct10000.com/gz/zt/200803S/sdy.htm'),imgtext:'链接3'},");
            photoJson.Append(
"{imgUrl:'http://www.gd.ehome.cn/EhomeClub/images/TImage4.jpg',imgLink:escape('http://onehome.gd.vnet.cn/htmlpages/huapi/index.htm'),imgtext:'链接4'},");
            photoJson.Append(
"{imgUrl:'http://www.gd.ehome.cn/EhomeClub/images/TImage5.jpg',imgLink:escape('http://www.gd.ct10000.com/gz/zt/200803S/hero1.htm'),imgtext:'链接5'},");
            photoJson.Append(
"{imgUrl:'http://www.gd.ehome.cn/EhomeClub/images/TImage6.jpg',imgLink:escape('http://www.gznet.com/telecom/zt/ehome0815/index.html'),imgtext:'链接6'},");
            photoJson.Append(
"{imgUrl:'http://www.gd.ehome.cn/EhomeClub/images/TImage7.jpg',imgLink:escape('http://www.gd.ct10000.com/gz/zt/200803S/jsyq.htm'),imgtext:'链接7'}");
            photoJson.Append(
"];");
            ScriptManager.RegisterStartupScript(
this.Page.Header, this.GetType(), "photoJson", photoJson.ToString(), true);
            
//Response.Write(photoJson.ToString());
        }
    }
}

 

2种方式实现的Demo

 

转载于:https://www.cnblogs.com/zhoulin/archive/2008/09/23/1296562.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Android播放图片demo实现可以使用Android的多媒体框架和UI控件。首先,需要在Android项目中创建一个新的活动或片段。 在活动或片段的布局文件中,可以使用ImageView控件来展示图片。可以通过在布局文件中添加ImageView控件,并设置其宽度、高度和其他属性来实现。 在Activity或Fragment的Java代码中,可以使用Java的多媒体框架来加载和播放图片。首先,需要从资源文件或外部存储中获取图片的位置,并将其转换为Bitmap对象。可以使用 BitmapFactory 类来实现这一步骤。 接下来,可以将 Bitmap 对象设置给 ImageView 控件来显示图片。可以使用 ImageView 的 setImageBitmap() 方法来实现。 如果需要实现循环播放多张图片,可以使用定时器或动画来切换不同的图片。可以使用 Android 的动画系统或计时器来实现这一功能。 如果要实现点击图片时切换下一张图片的功能,可以在图片的点击事件中切换图片。可以添加一个点击事件监听器到 ImageView 控件上,并在监听器中切换显示的图片。 最后,可以运行应用程序,并在手机或虚拟设备上观察图片播放效果。可以调整代码中的参数和逻辑来实现不同的图片播放效果。 总之,Android播放图片demo可以使用多媒体框架和UI控件来实现,在布局文件和Java代码中配置和设置图片的显示和播放。可以使用定时器或动画来实现循环播放和点击切换图片的功能。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值