zoukankan      html  css  js  c++  java
  • .net中如何生成Flash式的图片切换效果

    在做新闻发布系统的时候,目前有一种很流行的做法就是将多幅图片新闻的图片合成一个flash,flash右下角有12345等标记,可以在多幅图片中进行切换。

    这种方式在.net中的实现方式如下:

    第一步:首先在.Net后台生成javascript语句function indexpic()。

    private  void RegisterStartupScript()
        {
            string strKey="picflash";

    StringBuilder str=new StringBuilder ();
            str.Append ("<script type=text/javascript>function indexpic(){var focus_width=287;var focus_height=173;var text_height=20;");
            str.Append ("var swf_height = focus_height+text_height;");

    string pics="";
            string links="";
            string texts="";
            DataSet ds=commonfunction .GetPicNews ();
            int count=ds.Tables [0].Rows.Count;
            for(int i=0;i<count ;i++)
            {
                if(i!=0)pics+="|"+ds.Tables [0].Rows [i]["index_pic"].ToString ();
                else pics+=ds.Tables [0].Rows [i]["index_pic"].ToString ();
                if(i!=0) links +="|"+"SingleInfo.aspx?id="+ds.Tables [0].Rows [i]["id"].ToString ();
                else links +="SingleInfo.aspx?id="+ds.Tables [0].Rows [i]["id"].ToString ();
                if(i!=0)texts +="|"+ds.Tables [0].Rows [i]["title"].ToString ();
                else texts +=ds.Tables [0].Rows [i]["title"].ToString ();
               
            }
            str.Append ("var pics='"+pics+"';");
            str.Append (" var links='"+links+"';");
            str.Append (" var texts='"+texts+"';");     
            str.Append("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 +'/">');");
            str.Append("document.write('<param name=/"allowScriptAccess/" value=/"sameDomain/"><param name=/"movie/" value=/"http://travel.zjg.js.cn/config/pixviewer.swf/"><param name=/"quality/" value=/"high/"><param name=/"bgcolor/" value=/"#999898/">');");
            str.Append("document.write('<param name=/"menu/" value=/"false/"><param name=wmode value=/"opaque/">');");
            str.Append("document.write('<param name=/"FlashVars/" value=/"pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'/">');");
            str.Append("document.write('</object>');}</script>");
            Page.RegisterClientScriptBlock(strKey, str.ToString ());
        }

     

    第二步:在页面的pageload函数中注册此Javascript函数,方法如下:

    protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
                RegisterStartupScript();
        }

     

    第三步:在需要放置flash的地方(aspx页面中的某个位置),引用上面注册过的javascript函数

    <script  type ="text/javascript" >indexpic();</script>

  • 相关阅读:
    Sqlserver根据条件去除重复数据并且留下的是最大值数据
    C# Linq及Lamda表达式实战应用之 GroupBy 分组统计
    MVVM模式WPF的ComboBox数据绑定,使用Dictionary作为数据源
    C# System.Timers.Timer定时器的使用和定时自动清理内存应用
    SQL优化策略
    只要不放弃,总有出头之路
    2 Python基础
    4 动态库和静态库
    1 VS常用快捷键
    2 C语言环境、编译
  • 原文地址:https://www.cnblogs.com/huangjihua/p/4125224.html
Copyright © 2011-2022 走看看