网站首页图片动态更换显示【Flash】

最近网站改版,首页要显示图片新闻,效果如下:
网站首页图片动态更换显示【Flash】
主要是下载了个Flash,然后改了改代码。不过其中设计的问题还是觉得非常有必要记下来。下面是代码
 1 < script type = " text/javascript " >
 2                                                                                      <!--     
 3                                                                                     var focus_width = 154 // 156
 4                                                                                     var focus_height = 140 // 143
 5                                                                                     var text_height = 0
 6                                                                                     var swf_height  =  focus_height + text_height
 7                                                                                     var pics = ' <%= strPic %> '
 8                                                                                     var links = ' <%= strLink %> '
 9                                                                                      // var pics=' http://images.17173.com/cabal/2006-11/20061208b.jpg? | http://images.17173.com/cabal/2006-11/20061208b.jpg? | http://images.17173.com/cabal/2006-11/20061208a.jpg '
10                                                                                      // var links=' http://cabal.17173.com/wq/ssj.html | http://cabal.17173.com/zyjs/kjs_2.html | http://cabal.17173.com/dj/dj_2.html '
11                                                                                     var texts = ' 惊天动地热门话题|惊天动地热门话题222 '
12                                                                                     
13                                                                                     document.write( ' <table style="background-color:#ECECEC; width:100%;height:100%;" border="0px;" > ' );                                                                                
14                                                                                     document.write( ' <tr><td style="padding-left:1px;padding-right:1px;" nowrap="nowrap"> ' );    
15                                                                                     document.write( ' <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" align="middle" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width=" ' +  focus_width  + ' " height=" ' +  swf_height  + ' "> ' );
16                                                                                     document.write( ' <param name="allowScriptAccess" value="sameDomain"><param name="movie" value="News/focus.swf"> <param name="quality" value="high"><param name="bgcolor" value="#071923"> ' );
17                                                                                     document.write( ' <param name="menu" value="false"><param name=wmode value="transparent"> ' );
18                                                                                     document.write( ' <param name="FlashVars" value="pics= ' + pics + ' &links= ' + links + ' &texts= ' + texts + ' &borderwidth= ' + focus_width + ' &borderheight= ' + focus_height + ' &textheight= ' + text_height + ' "> ' );
19                                                                                     document.write( ' <embed src="News/focus.swf" wmode="opaque" FlashVars="texts= ' + texts + ' &pics= ' + pics + ' &links= ' + links + ' &borderwidth= ' + focus_width + ' &borderheight= ' + focus_height + ' &textheight= ' + text_height + ' " menu="false" bgcolor="#071923" quality="high" width=" ' +  focus_width  + ' " height=" ' +  swf_height  + ' " allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> ' );    document.write( ' </object> ' );
20                                                                                     document.write( ' </td> ' );
21                                                                                     document.write( ' </tr></table> ' );                            
22                                                                                      // -->
23                                                                                  </ script >

 1 // 取出Flash中图片Url和目标地址
 2              string  strHead  =  Request.Url.ToString().Substring( 0 , Request.Url.ToString().LastIndexOf( @" / " ));
 3         
 4             mnMain.NewsImage(sqlConn,  ref  strPic,  ref  strLink,  3 ,strHead);
 5
 6 // 取出旅游资讯Flash中要显示的图片的Url,以及目标地址
 7          public   void  NewsImage(SqlDatabaseConnection sqlConn, ref   string  strPic,  ref   string  strLink, int  PageCount, string  strHead)
 8          {
 9            string strSQL = "select  top "+PageCount.ToString()+" iSysCode,cGUID,cTitle,cDerivation,dDate,cImage,cImages,iKindCode,cKindName,iClick,iHot,iStatusCode" +
10                          " from Module_News where iStatusCode=3005001 and isnull(cImage,'')<>'' and iKindCode=3012003    order by iSysCode desc";
11
12            SqlDataReader sqlReader = sqlConn.ExecuteReader(strSQL);
13
14            while (sqlReader.Read())
15            {
16                strPic += strHead + sqlReader["cImage"].ToString()+"|";
17                strLink += strHead+@"/News/Read.aspx?id=" + sqlReader["cGUID"].ToString() + "|";
18            }

19            strPic = strPic.Substring(0, strPic.Length - 1);
20            strLink = strLink.Substring(0, strLink.Length - 1);
21            sqlReader.Close();
22        }


这其中因为有本地测试与发布之分,故使用Request.Url取出当前请求地址.使代码在发布前不必修改

你可能感兴趣的:(Flash)