asp.net flash图片轮换 焦点图 动态从数据库获取

来源:互联网 发布:俄克拉荷马大学 知乎 编辑:程序博客网 时间:2024/06/10 18:53

前台代码

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width='<%=focus_width %>' height='<%=swf_height %>'>
          <param name="allowScriptAccess" value="sameDomain" />
          <param name="movie" value="../flash/pixviewer.swf" />
          <param name="wmode" value="transparent" />
          <param name="quality" value="high" />
          <param name="menu" value="false" />
          <param name="wmode" value="opaque" />
          <param name="FlashVars" value="pics=<%=pics %>&links=<%=links %>&texts=<%=texts %>&borderwidth=<%=focus_width %>&borderheight=<%=focus_height %>&textheight=<%=text_height %>" />             
          <embed src="../falsh/pixviewer.swf" wmode="opaque" FlashVars="pics=<%=pics %>&links=<%=links %>&texts=<%=texts %>&borderwidth=<%=focus_width %>&borderheight=<%=focus_height %>&textheight=<%=text_height %>" menu="false" bgcolor="#DADADA" quality="high" width="<%=focus_width %>" height="<%=swf_height %>" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
        </object>

后台代码

    public int focus_width = 340;//flash和图片的宽
    public int focus_height = 310;//图片的高
    public int text_height = 19;//文字的高
    public int swf_height;//flash的高(图片的高+文字的高)
    public string pics;//图片地址
    public string texts;//标题
    public string links;//详细内容的地址
    private void Page_Load(object sender, System.EventArgs e)
    {
        if (!IsPostBack)
        {
            swf_height = focus_height + text_height;
            // 在此处放置用户代码以初始化页面
            string picstr = "", textstr = "", linkstr = "";
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRING"].ConnectionString);
            conn.Open();
            SqlCommand cmd = new SqlCommand("select top 4 id,picture,url_name,substring(title,0,15) as title from news_content where bigclassid='26' and picture<>''  order by times desc", conn);
            SqlDataReader read1 = cmd.ExecuteReader();
            while (read1.Read())
            {
                pics += "../upimages/" + read1["picture"].ToString() + "|";
                texts += read1["title"].ToString() + "|";
                links += "../news/html/" + read1["url_name"].ToString() + "|";
            }
            read1.Close();
            conn.Close();
            pics = pics.Remove(pics.Length - 1, 1);
            texts = texts.Remove(texts.Length - 1, 1);
            links = links.Remove(links.Length - 1, 1);   

原创粉丝点击