Flash Images 效果实现(原作)

 

      前一些时间,看到好多网站上的Flash Images新闻,效果很是不错.当时很是感兴趣,自己就想研究一下此效果是怎么实现的.于是Google,没有找到我想要的源代码,或在一个群里,一个网友给了他们公司一个同事一前用过的一段代码;但另人失望的是,那个代码是Javascript静态实现图片滚动新闻的;但我们实际应用中不可能做成静态的吧,那样就失去了灵活性.。

      我就自己研究,将其改为了动态从数据库取数据;哈哈,终于让我给做出来了,效果还算不错,现在拿出来和大家一起来分享,希望能帮上有需要的朋友。
            

先看一下效果:
      

 

前台代码:

       

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Imasges_News._Default" %>

<%@ Import namespace="Imasges_News.SqlHelp"%>

<%@ Import Namespace="System.Data" %>

<!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>

</head>

<body>

<form Id="a" runat="server">

<span class="f14b">

<script type="text/javascript">

 var focus_width=240

 var focus_height=200

 var text_height=18

 var swf_height = focus_height+text_height

var pics="<%=Return_Pics() %>";

var links="<%=Return_links() %>";

var texts="<%=Return_texts() %>";

 document.write('<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 +'">');

 document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="Flash/focus.swf"><param name="quality" value="high"><param name="bgcolor" value="#F0F0F0">');

 document.write('<param name="menu" value="false"><param name=wmode value="opaque">');

 document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">');

 document.write('<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" />'); document.write('</object>');

 </script>

</form>

</body>

</html>

后台代码:

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using Imasges_News.SqlHelp;

namespace Imasges_News

{  

    //Author:ziyan22

    //CreateDate:2007-07-01

    //Content:Flash Image

    public partial class _Default : System.Web.UI.Page

    {

        public DataTable DT;

        protected void Page_Load(object sender, EventArgs e)

        {

            if(!Page.IsPostBack)

            {

                Sys_Mess();

            }

           

        }

        public void Sys_Mess()

        {

            string connstring = System.Configuration.ConfigurationSettings.AppSettings["sqlConn"].ToString().Trim();

            DBUtil DbUtil;

            DbUtil = new DBUtil(connstring);

            System.Data.DataSet ds;

            ds = new DataSet();

            ds = DbUtil.Select_News();

            DT = ds.Tables[0];

        }

       

        public string Return_Pics()

        {

            string ImagesUrl="";

            int i;

            for(i=0;i<DT.Rows.Count;)

            {

                if (ImagesUrl!="")

                {

                    ImagesUrl = ImagesUrl + "|"+ DT.Rows[i]["imgUrl"].ToString() ;

                }

                else

                {

                    ImagesUrl = ImagesUrl + DT.Rows[i]["imgUrl"].ToString();

                }

                i++;

            }

            return ImagesUrl;

        }

       

        public string Return_links()

        {

            string ImgLink = "";

            int j;

            for (j = 0; j < DT.Rows.Count; )

            {

                if (ImgLink != "")

                {

                    ImgLink = ImgLink + "|" + DT.Rows[j]["imgLink"].ToString();

                }

                else

                {

                    ImgLink = ImgLink + DT.Rows[j]["imgLink"].ToString();

                }

                j++;

            }

            return ImgLink;

        }

        public string Return_texts()

        {

            string Imgtext = "";

            int n;

            for (n = 0; n < DT.Rows.Count; )

            {

                if (Imgtext != "")

                {

                    Imgtext = Imgtext + "|" + DT.Rows[n]["imgtext"].ToString();

                }

                else

                {

                    Imgtext = Imgtext + DT.Rows[n]["imgtext"].ToString();

                }

                n++;

            }

            return Imgtext;

        }

        protected void TextBox4_TextChanged(object sender, EventArgs e)

        {

        }

    }

}


表结构:

CREATE TABLE [dbo].[ImagesNews] (

       [ID] [int] IDENTITY (1, 1) NOT NULL ,

       [imgUrl] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,

       [imgtext] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,

       [imgLink] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL

) ON [PRIMARY]

GO

在就不提供代码包的下载了,空间毕竟有限.如有需要,,留言,Email给他.

原文地址:https://www.cnblogs.com/ziyan22/p/802056.html