动态绑定Flash的图片和标题

该博客介绍了一个使用Flash技术显示新闻文章中图片的方法。通过解析新闻内容获取图片链接,并将其与标题一起用于生成Flash幻灯片。代码实现了从文章列表中提取最多五篇文章的首张图片及其标题,最终以Flash组件形式在页面上展示。

public void showFlash()
    {
        IList<NewsArticle> articleList = article.ListNewsArticleByRows("22",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;
              
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值