動態綁定flash 中的圖片,圖片標題

來源:互聯網
上載者:User

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;
              
    }

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.