动态绑定flash 中的图片,图片标题

flash文件下载/Files/xiachufeng/focus1.swf

 

前台代码:

  <div runat="server" id="flashTD"></div>

 

后台代码

/// <summary>
    /// 动态绑定flash 中的图片,图片标题
    /// </summary>
    public void showFlash()
    {
        IList<NewsArticle> articleList = article.ListNewsArticleByRows("22",500);//后台方法 22是id ,500是显示500条数据

        int count = 0;
        string pics = ""; //图片路径
        string links = "";
        string texts = ""; //标题
        
        for (int i = 0; i < articleList.Count; i++)
        {
            NewsArticle articleNew = (NewsArticle)articleList[i];
            if (articleNew.Content == "")
            {
                continue;
            }
            string content = ((NewsArticle)articleList[i]).Content;
            int firstIndex = content.LastIndexOf("src=");
            if (firstIndex < 0)
            {
                continue;
            }
            else
            {
                int lastIndex = content.LastIndexOf("jpg")+3;
                string fileName = content.Substring(firstIndex+5,lastIndex-(firstIndex+5));
                 //fileName = "images/a1.jpg|images/a2.jpg|images/a3.jpg|images/a4.jpg|images/a5.jpg";
                pics += fileName;
                links += "PhySituationDetails.aspx?id="+articleNew.ArticleID;
                if (articleNew.Title.Length > 25)
                {
                    texts += articleNew.Title.Substring(0, 25) + "...";
                }
                else
                {
                    texts += articleNew.Title;
                }
                count++;
                if (count != 5)
                {
                    pics += "|";
                    links += "|";
                    texts += "|";
                }
            }
            if (count == 5)
            {
                break;
            }
        }
        string innerHtml = "<script type='text/javascript'>";
        innerHtml += "var focus_width=400;\n";
        innerHtml += "var focus_height=300;\n";
        innerHtml += "var text_height=25;\n";
        innerHtml += "var swf_height = focus_height + text_height;\n";
       // innerHtml += "var pics='" + pics + "';\n";
        innerHtml += "var pics='"+pics+"';\n";
        innerHtml += "var links='" + links + "';\n";
        innerHtml += "var texts='" + texts + "';\n";
        innerHtml += "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 +'\">');";
        innerHtml += "document.write('<param name=\"allowScriptAccess\" value=\"sameDomain\"><param name=\"movie\" value=\"focus1.swf\"><param name=\"quality\" value=\"high\"><param name=\"bgcolor\" value=\"#F0F0F0\">');";
        innerHtml += "document.write('<param name=\"menu\" value=\"false\"><param name=\"wmode\" value=\"opaque\">');";
        innerHtml += "document.write('<param name=\"FlashVars\" align=\"left\" value=\"pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'\">');";
        innerHtml += "document.write('</object>');";
        innerHtml += "</script>";
        this.flashTD.InnerHtml= innerHtml;
              
    }

posted @ 2010-07-01 13:05  你妹的sb  阅读(300)  评论(0编辑  收藏  举报
百度一下